/* * Client2.java * * Created on March 6, 2006, 5:06 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package headley.chat; import java.io.DataOutputStream; import java.net.Socket; /** * * @author Headley WIlliamson */ public class Client3 { /** * Creates a new instance of Client2 */ public Client3() { } public void startClient() { try { Socket socket = new Socket("localhost", 51234); // we are using local host, but we can use any ip addres // localhost means your current desktop you are working on. DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); for (int i = 0; i < 20; i++) { dos.writeUTF("Are we having fun yet? count:" +i); Thread.sleep(5000); } } catch (Exception ex) { ex.printStackTrace(); } } public static void main(String [] args) { new Client3().startClient(); } }