import java.io.*; import java.net.*; public class Send { public static void main(String[] args) throws IOException, UnknownHostException { Socket s = new Socket("localhost", 4711); PrintWriter sockOut = new PrintWriter(s.getOutputStream()); System.out.println("Client connected"); for(int i=0; i<10; i++) { System.out.println("client sending message no " + (i+1) ); sockOut.println("message no " + (i+1) ); } sockOut.close(); //Flushes the out stream. s.close(); } }