import java.net.*; import java.io.*; public class UDPEchoClient { public final static int DEFAULT_PORT = 7; public static void main(String[] args) { String hostname = "localhost"; int port = DEFAULT_PORT; if (args.length > 0) { hostname = args[0]; } if (args.length > 1) { try { port = Integer.parseInt(args[1]); } catch (Exception e) {} } try { InetAddress ia = InetAddress.getByName(hostname); SenderThread sender = new SenderThread(ia, DEFAULT_PORT); sender.start(); ReceiverThread receiver = new ReceiverThread(sender.getSocket()); receiver.start(); } catch (UnknownHostException e) { System.err.println(e); } catch (SocketException se) { System.err.println(se); } } // end main }