Skip to content
Snippets Groups Projects
Commit 0d79e777 authored by brutzman's avatar brutzman
Browse files

better default name for diagnostics, easily modifiable

parent 4a1a9beb
No related branches found
No related tags found
No related merge requests found
...@@ -16,8 +16,8 @@ import java.net.*; ...@@ -16,8 +16,8 @@ import java.net.*;
*/ */
public class UdpSender public class UdpSender
{ {
public static final String MY_NAME = "(default name)";
public static final int SENDING_PORT = 1414; public static final int SENDING_PORT = 1414;
public static final int RECEIVING_PORT = 1415; public static final int RECEIVING_PORT = 1415;
public static final String DESTINATION_HOST = "localhost"; public static final String DESTINATION_HOST = "localhost";
...@@ -45,6 +45,8 @@ public class UdpSender ...@@ -45,6 +45,8 @@ public class UdpSender
// ID of the host we are sending to // ID of the host we are sending to
InetAddress destinationAddress = InetAddress.getByName(DESTINATION_HOST); InetAddress destinationAddress = InetAddress.getByName(DESTINATION_HOST);
// ID of the host we are sending from
InetAddress sourceAddress = InetAddress.getByName("localhost"); // possibly identical if source not modified
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, destinationAddress, RECEIVING_PORT ); DatagramPacket packet = new DatagramPacket(buffer, buffer.length, destinationAddress, RECEIVING_PORT );
...@@ -58,7 +60,7 @@ public class UdpSender ...@@ -58,7 +60,7 @@ public class UdpSender
{ {
udpSocket.send(packet); udpSocket.send(packet);
Thread.sleep(1000); // Send 100, one per second Thread.sleep(1000); // Send 100, one per second
System.out.println("Bert Sent packet " + index + " of 100"); System.out.println(MY_NAME + " " + sourceAddress + " sent packet " + index + " of 100");
} }
System.out.println("UdpSender complete."); System.out.println("UdpSender complete.");
} }
......
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