From 65cc15b2e081ad3b68497107c9adfa91d13872ce Mon Sep 17 00:00:00 2001 From: brutzman <brutzman@nps.edu> Date: Mon, 12 Feb 2018 15:43:19 -0800 Subject: [PATCH] improved diagnostics, comments --- .../build/classes/tcpclient/TcpClient.class | Bin 1754 -> 1754 bytes .../TcpClient/nbproject/private/private.xml | 13 +++++++--- .../TcpClient/src/tcpclient/TcpClient.java | 2 +- .../tcpthreadserver/HandlerThread.class | Bin 1171 -> 1258 bytes .../tcpthreadserver/TcpThreadServer.class | Bin 1342 -> 1342 bytes .../nbproject/private/private.xml | 24 ++++++++++-------- .../src/tcpthreadserver/HandlerThread.java | 8 +++--- .../src/tcpthreadserver/TcpThreadServer.java | 5 ++-- 8 files changed, 31 insertions(+), 21 deletions(-) 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 GIT binary patch delta 54 zcmcb`dy98M8XE^g02hPp#+-9ZlkJ(sSa}#C7}7U~GS6q?5fb0Vz_N*fNqZZE#3VL9 K#`eknY~28pu?{-` delta 72 zcmcb`dy98M8XFgbEkgju#+-9Z(mV_i4C#yv!U0A3Nja&x3gww484AfcnW=dtn?srB cGx2C|V-VlOz$7HGje%tnn;&D_WPi490Q^=I#Q*>R diff --git a/projects/TcpExample4/TcpClient/TcpClient/nbproject/private/private.xml b/projects/TcpExample4/TcpClient/TcpClient/nbproject/private/private.xml index 475096252c..677f586b13 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 b9bd6d9bcd..63386b5536 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 GIT binary patch delta 603 zcmXYu&rTCj6vlru1@254YiW`CueMkf?Nn^B1t|pug#wn)L|ka%!UY%;|D{B?JOi2d z46ZR+j3z#SD__7BI}_LLjNdIi$(%XgJ>NO!JNHKZZ~w`Ue_y`?Ra$XI34PL(e6BO; zaU+hQ9H+vR;id)EK~ZHBNspT4PkYSR#4XF3^{5->EN&R)4Ga5^e+6c1ZDV=!;g*B5 z9@U(7GD9xl6k~?l0e2`w@0~(oktM_3fO{-Eq@!^sT@J{w;!t?7-Fdg&spsE3eY^Yo z)wBH0>rTGkbG}lRz1$6GvKk#Z1#itZUndtO+}hA0_Z_nPKeN$}d$gC9UU2kjxV)=4 z!)f_5LMy_q{_)}=PBHw9d(h*Yl}`|p&oaOTd~%!<8arllUgy^0y{=kPoLs->AJy3# zYkwq`+8gLHSp0<BWvKNH^C&#T+Ze@Pve{uJ6@MWprA{a=bx9nPPug@+M;{n&DGs}& z4m1GWRg)2ouoCMM2}L|TU6M(yRF<#`mzg5e>sEMCqsBB1W>nZv=`5?vvB^SjpQ@B5 sMa(naQy+4Xf_BU@!6mhciEX$dWJkCAdtX)T<Nl>-7%@s+(}7FzKi7gy!~g&Q delta 480 zcmXYt&rTCz6vclt1Nmmkh-1+rlvbdWLjTZOTKUtW{ArN|AtdfhSajh66Coju8$x^r zGfVffMoB|h@Bk)0f-m4Jm>ADToXOm|_k8Evd%pWSh=aF3{@&gJ4fYa@u@I1CF`!7v zr<}l0Nw7rKP_xDJVNvxIB1^9OEL*f;DNUajh80_{8rBT!pO1dUd(J_WA{+9UCx%u? zo7woQlPhiT((o!|lP!m__q~t3>hWpy@a*`c|E7QTuJ<7%#dgRJop{pC`CZ#&mu%d1 zo8AVmzhAhXlTOM7IQrCI(N&&eT=8lA#Y=Z5gpJ}UW*8z%z%wRQrNo2;X{PkInbkXb zGh#_C?5A{A*@^#nQ=e`aDJR1L!{q@Fir2UUM!(@D9}2o;WM6q{z@saPVU-q<#CCk0 zP_c+lMc9(CnoQKmv&^E_UZW}gx)du~&YCXVzPDJE;fMusr`5ADp=5?x`EF~&Ip*#M Vb^hNVuMr0K+z=TZ%&T-M`~wD2H%$Nl 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 GIT binary patch delta 29 jcmdnTwU2AVITk?~1_cIr21Ov$WKd#oVo;rYpCujuXFdi< delta 29 jcmdnTwU2AVITk@#1_dBgWKd$zWKd>sVo;lWpCujuXMYAw diff --git a/projects/TcpExample4/TcpThreadServer/TcpThreadServer/nbproject/private/private.xml b/projects/TcpExample4/TcpThreadServer/TcpThreadServer/nbproject/private/private.xml index e1d572803b..2c9ba6601e 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 82b7798cce..5dd36ab12d 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 af1a103847..c7b0b2a99a 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 } } -- GitLab