Java tutorial
import java.io.DataOutputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; class ServerSocketDemo { public static void main(String args[]) throws Exception { int port = Integer.parseInt(args[0]); ServerSocket ss = new ServerSocket(port); while (true) { Socket s = ss.accept(); OutputStream os = s.getOutputStream(); DataOutputStream dos = new DataOutputStream(os); dos.writeInt(1); s.close(); } } }