diff --git a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverB.java b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverB.java index 06765cff1fb730a62a921e66532c29df7acf3549..6b8c30b70966bf4d6e13c653aa5399f5ac285b1e 100644 --- a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverB.java +++ b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverB.java @@ -37,13 +37,13 @@ public class ABEspduReceiverB { // Specify the socket to receive data socket = new MulticastSocket(3101); socket.setBroadcast(true); - int connectionCount = 0; - ServerSocket serverSocket = new ServerSocket(2999); - Socket clientConnection = serverSocket.accept(); + //int connectionCount = 0; + // ServerSocket serverSocket = new ServerSocket(2999); + //Socket clientConnection = serverSocket.accept(); - InputStream is = clientConnection.getInputStream(); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); + //InputStream is = clientConnection.getInputStream(); + //InputStreamReader isr = new InputStreamReader(is); + //BufferedReader br = new BufferedReader(isr); address = InetAddress.getByName(GROUP); socket.joinGroup(address); @@ -62,18 +62,18 @@ public class ABEspduReceiverB { - String serverMessage = br.readLine(); - System.out.println("The message the client sent was " + serverMessage); + //String serverMessage = br.readLine(); + //System.out.println("The message the client sent was " + serverMessage); // 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(); + // InetAddress localAddress = clientConnection.getLocalAddress(); + //InetAddress remoteAddress = clientConnection.getInetAddress(); - int localPort = clientConnection.getLocalPort(); - int remotePort = clientConnection.getPort(); + //int localPort = clientConnection.getLocalPort(); + //int remotePort = clientConnection.getPort(); // My socket pair connection looks like this, to localhost: // Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54876 )) @@ -83,10 +83,10 @@ public class ABEspduReceiverB { // different ports? - System.out.println("Socket pair: (( " + localAddress.toString() + ", " + localPort + " ), ( " + - remoteAddress.toString() + ", " + remotePort + " ))"); + //System.out.println("Socket pair: (( " + localAddress.toString() + ", " + localPort + " ), ( " + + // remoteAddress.toString() + ", " + remotePort + " ))"); - System.out.println("Connection count is: " + connectionCount); + //System.out.println("Connection count is: " + connectionCount); List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData()); System.out.println("Bundle size is " + pduBundle.size()); diff --git a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduSenderB.java b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduSenderB.java index e488ead683af89f2bed4f937ba3d162110e698a2..99a064c7b1a2674a2e3dc59c25a292eec4cf7c51 100644 --- a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduSenderB.java +++ b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduSenderB.java @@ -56,6 +56,7 @@ public static void main(String args[]) try { destinationIp = InetAddress.getByName(DEFAULT_MULTICAST_GROUP); + } catch(Exception e) { @@ -151,6 +152,13 @@ public static void main(String args[]) // Loop through sending N ESPDUs try { + int connectionCount = 0; + ServerSocket serverSocket = new ServerSocket(2999); + Socket clientConnection = serverSocket.accept(); + + InputStream is = clientConnection.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); System.out.println("Sending " + NUMBER_TO_SEND + " ESPDU packets to " + destinationIp.toString()); for(int idx = 0; idx < NUMBER_TO_SEND; idx++) { @@ -232,6 +240,32 @@ public static void main(String args[]) FirePdu fire = new FirePdu(); byte[] fireArray = fire.marshal(); + String serverMessage = br.readLine(); + System.out.println("The message the client sent was " + serverMessage); + + // 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(); + + int localPort = clientConnection.getLocalPort(); + int remotePort = clientConnection.getPort(); + + // My socket pair connection looks like this, to localhost: + // 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? + + + System.out.println("Socket pair: (( " + localAddress.toString() + ", " + localPort + " ), ( " + + remoteAddress.toString() + ", " + remotePort + " ))"); + + System.out.println("Connection count is: " + connectionCount); + // The byte array here is the packet in DIS format. We put that into a // datagram and send it. byte[] data = baos.toByteArray();