FileDocCategorySizeDatePackage
UDPServer.javaAPI DocExample852Tue Feb 22 13:23:26 GMT 2005None

UDPServer

public abstract class UDPServer extends Thread

Fields Summary
private int
bufferSize
protected DatagramSocket
ds
Constructors Summary
public UDPServer(int port, int bufferSize)

    this.bufferSize = bufferSize;
    this.ds = new DatagramSocket(port);
  
public UDPServer(int port)

    this(port, 8192);
  
Methods Summary
public abstract voidrespond(java.net.DatagramPacket request)

public voidrun()

  
    byte[] buffer = new byte[bufferSize];
    while (true) {
      DatagramPacket incoming = new DatagramPacket(buffer, buffer.length);
      try {
        ds.receive(incoming);
        this.respond(incoming);
      }
      catch (IOException e) {
        System.err.println(e);
      }      
    } // end while