Java examples for Network:ServerSocket
TCP server that runs on port 9090
import java.io.IOException; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.Date; public class Server { public static void main(String[] args) throws IOException { ServerSocket listener = new ServerSocket(9090); try {// www. j a va2 s .c o m while (true) { Socket socket = listener.accept(); try { PrintWriter out = new PrintWriter(socket.getOutputStream(), true); out.println("asdf"); } finally { socket.close(); } } } finally { listener.close(); } } }