diff --git a/projects/TcpExample3/Server/TcpServer/src/tcpserver/TcpServer.java b/projects/TcpExample3/Server/TcpServer/src/tcpserver/TcpServer.java index 9d0ca372d12087b1bdc80a772144d7fd1be24826..b8a77f146cfa1fb4c7cebcf0e037e1b7da5ad317 100644 --- a/projects/TcpExample3/Server/TcpServer/src/tcpserver/TcpServer.java +++ b/projects/TcpExample3/Server/TcpServer/src/tcpserver/TcpServer.java @@ -31,17 +31,21 @@ public class TcpServer { // Notice that it is outside the loop; ServerSocket // needs to be made only once. + System.out.println("TcpServer has started..."); // it helps debugging to put this on console first ServerSocket serverSocket = new ServerSocket(2317); + // Server is up and waiting (i.e. "blocked" or paused) // Loop, infinitely, waiting for client connections. // Stop the program somewhere else. while (true) { - Socket clientConnection = serverSocket.accept(); // block until connected + Socket clientConnection = serverSocket.accept(); // block until connected to a client + + // Now hook everything up (i.e. set up the streams), Java style: OutputStream os = clientConnection.getOutputStream(); - PrintStream ps = new PrintStream(os); + PrintStream ps = new PrintStream(os); - ps.println("This was written by the server"); + ps.println("This was written by the server"); // this goes back to client! // Print some information locally about the Socket // connection. This includes the port and IP numbers