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

improved diagnostics, comments

parent 6775ca62
No related branches found
No related tags found
No related merge requests found
Showing with 31 additions and 21 deletions
No preview for this file type
<?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>
......@@ -47,8 +47,8 @@ public class TcpClient
}
catch(Exception e)
{
System.out.println(e);
System.out.println("Problem with client");
System.out.println(e);
}
}
......
<?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>
......@@ -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();
......
......@@ -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
}
}
......
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