FileDocCategorySizeDatePackage
UDPEchoServer.javaAPI DocExample1075Sat Sep 09 20:51:42 BST 2000None

UDPEchoServer

public class UDPEchoServer extends UDPServer

Fields Summary
public static final int
DEFAULT_PORT
Constructors Summary
public UDPEchoServer()


      
    this(DEFAULT_PORT); 
  
public UDPEchoServer(int port)

    super(port); 
    ds.setReceiveBufferSize(32768);
  
Methods Summary
public static voidmain(java.lang.String[] args)

 
   try {
     if (args.length > 0) {
       int port = Integer.parseInt(args[0]);
       UDPEchoServer server = new UDPEchoServer(port);
       server.start();       
     }
     else {
       UDPEchoServer server = new UDPEchoServer();
       server.start();
     }
   }
   catch (SocketException e) {
     System.err.println(e);
   }
 
  
public voidrespond(java.net.DatagramPacket incoming)


    try {
      DatagramPacket outgoing = new DatagramPacket(incoming.getData(), 
       incoming.getLength(), incoming.getAddress(), incoming.getPort());
      ds.send(outgoing);
      System.out.println(incoming.getLength());
    }
    catch (IOException e) {
      System.err.println(e);
    }