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

fix warnings, rename class to match filename

parent 3ac922ba
No related branches found
No related tags found
No related merge requests found
package edu.nps.moves.examples; // package edu.nps.moves.examples; // copy example from OpenDIS distribution, modify to serve as template
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
...@@ -15,28 +15,30 @@ import edu.nps.moves.disenum.*; ...@@ -15,28 +15,30 @@ import edu.nps.moves.disenum.*;
* @author DMcG * @author DMcG
* @version $Id:$ * @version $Id:$
*/ */
public class PduSender { public class OpenDisPduSender {
public static final int PORT = 62040; public static final int PORT = 3000;
public static final String MULTICAST_ADDRESS = "239.1.2.3"; public static final String MULTICAST_ADDRESS = "239.1.2.3";
private int port; private int port;
InetAddress multicastAddress; InetAddress multicastAddress;
public PduSender(int port, String multicast) { public OpenDisPduSender(int port, String multicast)
{
try { try {
this.port = port; this.port = port;
multicastAddress = InetAddress.getByName(multicast); multicastAddress = InetAddress.getByName(multicast);
if (!multicastAddress.isMulticastAddress()) { if (!multicastAddress.isMulticastAddress()) {
System.out.println("Not a multicast address: " + multicast); System.out.println("Not a multicast address: " + multicast);
} }
} catch (Exception e) { }
System.out.println("Unable to open socket"); catch (UnknownHostException e) {
System.out.println("Unable to open socket: " + e);
} }
} }
public void run() { public void run() {
try { try {
List<Pdu> generatedPdus = new ArrayList<Pdu>(); List<Pdu> generatedPdus = new ArrayList<>();
// Loop through all the enumerated PDU types, create a PDU for each type, // Loop through all the enumerated PDU types, create a PDU for each type,
// and add that PDU to a list. // and add that PDU to a list.
...@@ -148,17 +150,21 @@ public class PduSender { ...@@ -148,17 +150,21 @@ public class PduSender {
//PduContainer container = new PduContainer(); //PduContainer container = new PduContainer();
//container.setPdus(generatedPdus); //container.setPdus(generatedPdus);
//container.marshallToXml("examplePdus.xml"); //container.marshallToXml("examplePdus.xml");
} catch (Exception e) { }
catch (IOException e) {
System.out.println(e); System.out.println(e);
} }
} }
public static void main(String args[]) { public static void main(String args[]) {
if (args.length == 2) { if (args.length == 2) {
PduSender sender = new PduSender(Integer.parseInt(args[0]), args[1]); OpenDisPduSender sender = new OpenDisPduSender(Integer.parseInt(args[0]), args[1]);
sender.run(); sender.run();
} else { } else {
System.out.println("Usage: PduSender <port> <multicast group>"); System.out.println("Usage: OpenDisPduSender <port> <multicast group>");
System.out.println("Default: OpenDisPduSender " + PORT + " " + MULTICAST_ADDRESS);
OpenDisPduSender sender = new OpenDisPduSender(PORT, MULTICAST_ADDRESS);
sender.run();
} }
} }
} }
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