Skip to content
Snippets Groups Projects
Commit 9bbb4b11 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

classroom touchups

parent 5ed66a0a
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment