import java.lang.Thread; import java.net.*; import java.io.*; import java.util.StringTokenizer; import gnu.regexp.*; import gnu.getopt.*; class TestNet implements Runnable { private String domain; private boolean watcherrunning = false; private boolean isMulticastAddress = false; private Thread broadcastListener ; private DatagramSocket broadcast; /* supervision socket */ // it can also be a MulticastSocket, which inherits from the previous public void run() { byte buf[] = new byte[256]; DatagramPacket packet=new DatagramPacket(buf, 256); int port; String s = "Server waiting for Broadcast on "+domain; s+=(isMulticastAddress)?" (TCP multicast)":" (UDP broadcast)"; System.out.println(s); while( watcherrunning ) try { broadcast.receive(packet); String msg = new String(buf) ; // clean up the buffer after each message for (int i=0;i