Skip to content
Snippets Groups Projects
Commit 37dfa99f authored by brutzman's avatar brutzman
Browse files

cleanup comments, warnings

parent 43cdf456
No related branches found
No related tags found
No related merge requests found
......@@ -18,11 +18,10 @@ import java.net.*;
* <code>telnet ipOfServersLaptop 2317</code>
*
* And have that machine display the socket pairs received.
* @author mcgredo
* @author mcgredo, brutzman
*/
public class TcpExample2ConnectionCounting
{
public static void main(String[] args)
{
try
......@@ -31,8 +30,7 @@ public class TcpExample2ConnectionCounting
System.out.println(" enter (nc localhost 2317) or (telnet localhost 2317)..." );
// ServerSocket waits for a connection from a client.
// Notice that it is outside the loop; ServerSocket
// needs to be made only once.
// Notice that it is outside the loop; ServerSocket needs to be made only once.
int connectionCount = 0; // state variable
......@@ -55,9 +53,8 @@ public class TcpExample2ConnectionCounting
ps.println("You were connection #" + connectionCount + ", by my count");
// 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();
......@@ -69,8 +66,7 @@ public class TcpExample2ConnectionCounting
// Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54876 )) note IPv6
// 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 first IP/port the same, while the second set has different ports?
System.out.println("Socket pair: (( " + localAddress.toString() + ", " + localPort + " ), ( " +
remoteAddress.toString() + ", " + remotePort + " ))");
......@@ -85,7 +81,7 @@ public class TcpExample2ConnectionCounting
clientConnection.close();
}
}
catch(Exception e)
catch(IOException e)
{
System.out.println("problem with networking: " + e);
}
......
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