FileDocCategorySizeDatePackage
LoggingUDPDiscardServer.javaAPI DocExample864Sun Dec 12 10:53:42 GMT 2004None

LoggingUDPDiscardServer

public class LoggingUDPDiscardServer extends UDPServer

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

  
      
    super(DEFAULT_PORT);
  
Methods Summary
public static voidmain(java.lang.String[] args)

 
   try {
     UDPServer erver = new LoggingUDPDiscardServer();
     server.start();
   }
   catch (SocketException ex) {
     System.err.println(ex);
   }
 
  
public voidrespond(java.net.DatagramPacket packet)

    
    byte[] data = new byte[packet.getLength()];
    System.arraycopy(packet.getData(), 0, data, 0, packet.getLength());
    try {
      String s = new String(data, "8859_1");
      System.out.println(packet.getAddress() + " at port " 
       + packet.getPort() + " says " + s);
    }
    catch (java.io.UnsupportedEncodingException ex) {
      // This shouldn't happen
    }