FileDocCategorySizeDatePackage
UDPEchoClient.javaAPI DocExample822Sat Sep 09 20:51:48 BST 2000None

UDPEchoClient

public class UDPEchoClient extends Object

Fields Summary
public static final int
DEFAULT_PORT
Constructors Summary
Methods Summary
public static voidmain(java.lang.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);
    }