Skip to content
Snippets Groups Projects
Commit 418f9f8c authored by brutzman's avatar brutzman
Browse files

runnability adjustments

parent a1139c5c
No related branches found
No related tags found
No related merge requests found
......@@ -67,7 +67,7 @@ public class TcpExample1Telnet
System.out.println("*** Problem with networking: " + e);
// Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException)
System.out.println("*** Be sure to stop any other running instances of this program!");
System.out.println("*** Be sure to stop any other running instances of programs using this port!");
}
}
}
......@@ -87,7 +87,7 @@ public class TcpExample2ConnectionCounting
System.out.println("problem with networking: " + e);
// Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException)
System.out.println("*** Be sure to stop any other running instances of this program!");
System.out.println("*** Be sure to stop any other running instances of programs using this port!");
}
}
}
......@@ -41,7 +41,7 @@ public class TcpExample3Client {
String serverMessage = br.readLine();
System.out.println("==================================================");
System.out.println("Now we're talking!");
System.out.println("The message the server sent was " + serverMessage);
System.out.println("The message the server sent was '" + serverMessage + "'");
// socket gets closed, either automatically/silently this code (or possibly by server)
} // end while(true)
}
......@@ -50,7 +50,7 @@ public class TcpExample3Client {
System.out.println(e);
// Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException)
System.out.println("*** Be sure to stop any other running instances of this program!");
System.out.println("*** Be sure to stop any other running instances of programs using this port!");
}
// program exit: tell somebody about that
System.out.println("client exit");
......
......@@ -4,8 +4,8 @@ import java.io.*;
import java.net.*;
/**
* Very slightly more complex than example1. A complete copy of example 2. The
* only thing this does differently is introduce a loop into the response, so
* Very slightly more complex than example1, further modifying example 2.
* The only thing this does differently is introduce a loop into the response, so
* you don't have to restart the program after one response. Also, it prints out
* the socket pair the server sees. Run the program via telnet several times and
* compare the socket pairs.
......@@ -17,7 +17,7 @@ import java.net.*;
*
* telnet [ipNumberOfServerLaptop] 2317
*
* And have him display the socket pairs he got.
* And have the instructor display the socket pairs received.
*
* @author mcgredo
*/
......@@ -31,7 +31,7 @@ public class TcpExample3Server {
// Notice that it is outside the loop; ServerSocket
// needs to be made only once.
System.out.println("TcpExample3Server has really started..."); // it helps debugging to put this on console first
System.out.println("TcpExample3Server 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)
......@@ -45,11 +45,10 @@ public class TcpExample3Server {
OutputStream os = clientConnection.getOutputStream();
PrintStream ps = new PrintStream(os);
ps.println("This was written by the server"); // this goes back to client!
ps.println("This message was produced by the server."); // this gets sent back to client!
// Print some information locally about the Socket
// connection. This includes the port and IP numbers
// on both sides (the socket pair.)
// Print some information locally about the Socket connection.
// This includes the port and IP numbers on both sides (the socket pair).
InetAddress localAddress = clientConnection.getLocalAddress();
InetAddress remoteAddress = clientConnection.getInetAddress();
......@@ -60,8 +59,7 @@ public class TcpExample3Server {
// Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54876 ))
// Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54881 ))
//
// Why is the first IP/port the same, while the second set has
// different ports?
// Why is the first IP/port the same, while the second set has different ports?
System.out.println("TcpExample3Server socket pair: (( " + localAddress.toString() + ", " + localPort + " ), ( "
+ remoteAddress.toString() + ", " + remotePort + " ))");
......@@ -78,7 +76,7 @@ public class TcpExample3Server {
System.out.println("problem with networking");
// Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException)
System.out.println("*** Be sure to stop any other running instances of this program!");
System.out.println("*** Be sure to stop any other running instances of programs using this port!");
}
}
}
......@@ -45,7 +45,7 @@ public class TcpExample4HandlerThread extends Thread
OutputStream os = socket.getOutputStream();
PrintStream ps = new PrintStream(os);
final long TIMEOUT = 10000; // 10000 milliseconds = 10 seconds
final long TIMEOUT = 2000; // 2000 milliseconds = 2 seconds, 10000 milliseconds = 10 seconds
System.out.println("TcpExample4HandlerThread pausing for TIMEOUT=" + TIMEOUT + "ms"); // debug
Thread.sleep(TIMEOUT); // 10 seconds
......
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