FileDocCategorySizeDatePackage
EchoOutputThread.javaAPI DocExample764Sun Dec 12 10:53:40 GMT 2004None

EchoOutputThread

public class EchoOutputThread extends Thread

Fields Summary
DatagramSocket
socket
private boolean
stopped
Constructors Summary
public EchoOutputThread(DatagramSocket ds)


       
    this.socket = ds;
  
Methods Summary
public voidhalt()

    this.stopped = true; 
  
public voidrun()


    byte[] buffer = new byte[65507];
    while (true) {
      if (stopped) return;
      DatagramPacket dp = new DatagramPacket(buffer, buffer.length);
      try {
        socket.receive(dp);
        String s = new String(dp.getData(), 0, dp.getLength());
        System.out.println(s);
        Thread.yield();
      }
      catch (IOException e) {
        System.err.println(e);
      } 
     
    }