diff --git a/projects/TcpExample4/TcpClient/TcpClient/build/classes/tcpclient/TcpClient.class b/projects/TcpExample4/TcpClient/TcpClient/build/classes/tcpclient/TcpClient.class index 9e6193d5fac6f9dc4f269dc766030e2048d3b2ea..f52b3948396a954fb2fc56ba07d118e68489d498 100644 Binary files a/projects/TcpExample4/TcpClient/TcpClient/build/classes/tcpclient/TcpClient.class and b/projects/TcpExample4/TcpClient/TcpClient/build/classes/tcpclient/TcpClient.class differ diff --git a/projects/TcpExample4/TcpClient/TcpClient/nbproject/private/private.xml b/projects/TcpExample4/TcpClient/TcpClient/nbproject/private/private.xml index 475096252cac3c06d37436d2d3de93d8858d0452..677f586b136628aa810ddaacdbe5ae89debeefc4 100644 --- a/projects/TcpExample4/TcpClient/TcpClient/nbproject/private/private.xml +++ b/projects/TcpExample4/TcpClient/TcpClient/nbproject/private/private.xml @@ -1,4 +1,9 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> - <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> -</project-private> +<?xml version="1.0" encoding="UTF-8"?> +<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> + <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> + <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> + <group name="MV3500 networking open-dis"> + <file>file:/E:/x-nps-gitlab/NetworkedGraphicsMV3500/projects/TcpExample4/TcpClient/TcpClient/src/tcpclient/TcpClient.java</file> + </group> + </open-files> +</project-private> diff --git a/projects/TcpExample4/TcpClient/TcpClient/src/tcpclient/TcpClient.java b/projects/TcpExample4/TcpClient/TcpClient/src/tcpclient/TcpClient.java index b9bd6d9bcd78c17fe5bef412d35aa19687e56fb4..63386b553660738092dfd002b752b85e1d957ecc 100644 --- a/projects/TcpExample4/TcpClient/TcpClient/src/tcpclient/TcpClient.java +++ b/projects/TcpExample4/TcpClient/TcpClient/src/tcpclient/TcpClient.java @@ -47,8 +47,8 @@ public class TcpClient } catch(Exception e) { - System.out.println(e); System.out.println("Problem with client"); + System.out.println(e); } } diff --git a/projects/TcpExample4/TcpThreadServer/TcpThreadServer/build/classes/tcpthreadserver/HandlerThread.class b/projects/TcpExample4/TcpThreadServer/TcpThreadServer/build/classes/tcpthreadserver/HandlerThread.class index c4b9d2fb168d0d0412ac2b1c06af5816539b7522..7a921b68cb4aab746feea6a3f1c1756c12549a71 100644 Binary files a/projects/TcpExample4/TcpThreadServer/TcpThreadServer/build/classes/tcpthreadserver/HandlerThread.class and b/projects/TcpExample4/TcpThreadServer/TcpThreadServer/build/classes/tcpthreadserver/HandlerThread.class differ diff --git a/projects/TcpExample4/TcpThreadServer/TcpThreadServer/build/classes/tcpthreadserver/TcpThreadServer.class b/projects/TcpExample4/TcpThreadServer/TcpThreadServer/build/classes/tcpthreadserver/TcpThreadServer.class index 12e6bb39824c3bbfafc84d2fe09e87e925be1b46..563756d8ae0965b8a41c17fb7b479d7c6ccde9ee 100644 Binary files a/projects/TcpExample4/TcpThreadServer/TcpThreadServer/build/classes/tcpthreadserver/TcpThreadServer.class and b/projects/TcpExample4/TcpThreadServer/TcpThreadServer/build/classes/tcpthreadserver/TcpThreadServer.class differ diff --git a/projects/TcpExample4/TcpThreadServer/TcpThreadServer/nbproject/private/private.xml b/projects/TcpExample4/TcpThreadServer/TcpThreadServer/nbproject/private/private.xml index e1d572803b0834e34f0e46b5c03639ecc7e5b2a1..2c9ba6601e23058e25a0da11b4bf126041a26d21 100644 --- a/projects/TcpExample4/TcpThreadServer/TcpThreadServer/nbproject/private/private.xml +++ b/projects/TcpExample4/TcpThreadServer/TcpThreadServer/nbproject/private/private.xml @@ -1,10 +1,14 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> - <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> - <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> - <group> - <file>file:/Users/mcgredo/projects/gitlab/NetworkedGraphicsMV3500/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/TcpThreadServer.java</file> - <file>file:/Users/mcgredo/projects/gitlab/NetworkedGraphicsMV3500/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/HandlerThread.java</file> - </group> - </open-files> -</project-private> +<?xml version="1.0" encoding="UTF-8"?> +<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> + <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> + <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> + <group> + <file>file:/Users/mcgredo/projects/gitlab/NetworkedGraphicsMV3500/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/TcpThreadServer.java</file> + <file>file:/Users/mcgredo/projects/gitlab/NetworkedGraphicsMV3500/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/HandlerThread.java</file> + </group> + <group name="MV3500 networking open-dis"> + <file>file:/E:/x-nps-gitlab/NetworkedGraphicsMV3500/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/HandlerThread.java</file> + <file>file:/E:/x-nps-gitlab/NetworkedGraphicsMV3500/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/TcpThreadServer.java</file> + </group> + </open-files> +</project-private> diff --git a/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/HandlerThread.java b/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/HandlerThread.java index 82b7798cce96123711a7fa5ba4938d17fae0b85d..5dd36ab12db915ca137f1a509fb1ccf0263105db 100644 --- a/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/HandlerThread.java +++ b/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/HandlerThread.java @@ -19,7 +19,7 @@ public class HandlerThread extends Thread /** The socket connection to a client */ Socket socket; - /** The threat creator creates the socket from + /** The thread constructor creates the socket from * a ServerSocket, and passes one to the thread * responsible for handling the connection. * @@ -32,7 +32,7 @@ public class HandlerThread extends Thread /** Handles one connection. We add an artificial slowness * to handling the connection with a sleep(). This means - * the client won't see a server connection response for ten seconds. + * the client won't see a server connection response for ten seconds (default). * */ public void run() @@ -45,7 +45,9 @@ public class HandlerThread extends Thread OutputStream os = socket.getOutputStream(); PrintStream ps = new PrintStream(os); - Thread.sleep(10000); + final long TIMEOUT = 10000; // 10000 + System.out.println("Server: pausing for TIMEOUT=" + TIMEOUT + "ms"); // debug + Thread.sleep(TIMEOUT); // 10 seconds ps.println("This was written by the server"); ps.flush(); diff --git a/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/TcpThreadServer.java b/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/TcpThreadServer.java index af1a103847638bc7204b45be47b8cd8bbcf4cc6c..c7b0b2a99ab5408f6c5a5eafc80cef794ff39f08 100644 --- a/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/TcpThreadServer.java +++ b/projects/TcpExample4/TcpThreadServer/TcpThreadServer/src/tcpthreadserver/TcpThreadServer.java @@ -21,11 +21,10 @@ public class TcpThreadServer { while(true) { - Socket clientConnection = serverSocket.accept(); + Socket clientConnection = serverSocket.accept(); // block until connected HandlerThread handlerThread = new HandlerThread(clientConnection); - handlerThread.start(); - + handlerThread.start(); // invokesthe run() method in that object } }