FileDocCategorySizeDatePackage
UDPServer.javaAPI DocExample815Sat Sep 09 20:52:04 BST 2000None

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