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

comments

parent 6eb529a9
No related branches found
No related tags found
No related merge requests found
...@@ -42,16 +42,21 @@ public class TcpExample4DispatchServer ...@@ -42,16 +42,21 @@ public class TcpExample4DispatchServer
System.out.println(TcpExample4DispatchServer.class.getName() + " ready to accept socket connections..."); System.out.println(TcpExample4DispatchServer.class.getName() + " ready to accept socket connections...");
while (true) // infinite loop while (true) // infinite loop
{ {
clientConnection = serverSocket.accept(); // block until connected clientConnection = serverSocket.accept(); // block! until connected
connectionCount++; // unblocked, got another connection connectionCount++; // unblocked, got another connection
// TODO provide initial message *to the client* that we are handing off to a dispatch thread... because that is polite behavior.
// plenty of code in Example3, we will let TcpExample4HandlerThread introduce itself
System.out.println("============================================================="); System.out.println("=============================================================");
System.out.println(TcpExample4DispatchServer.class.getName() + ".handlerThread invocation for connection #" + connectionCount + "..."); System.out.println(TcpExample4DispatchServer.class.getName() + ".handlerThread created for connection #" + connectionCount + "...");
handlerThread = new TcpExample4HandlerThread(clientConnection); handlerThread = new TcpExample4HandlerThread(clientConnection); // hand off the aready-created, connected socket to constructor
handlerThread.start(); // invokes the run() method in that object handlerThread.start();// invokes the run() method in that object
System.out.println(TcpExample4DispatchServer.class.getName() + ".handlerThread is launched, awaiting another connection..."); System.out.println(TcpExample4DispatchServer.class.getName() + ".handlerThread is now dispatched and running, using most recent connection...");
} }
} catch (IOException e) { }
catch (IOException e) {
System.out.println("Problem with " + TcpExample4DispatchServer.class.getName() + " networking:"); // describe what is happening System.out.println("Problem with " + TcpExample4DispatchServer.class.getName() + " networking:"); // describe what is happening
System.out.println("Error: " + e); System.out.println("Error: " + e);
// Provide more helpful information to user if exception occurs due to running twice at one time // Provide more helpful information to user if exception occurs due to running twice at one time
......
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