FileDocCategorySizeDatePackage
echoInputThread.javaAPI DocExample905Thu Apr 03 15:25:00 BST 1997None

echoInputThread

public class echoInputThread extends Thread

Fields Summary
InetAddress
server
int
echoPort
DatagramSocket
theSocket
Constructors Summary
public echoInputThread(InetAddress ia, DatagramSocket ds)

  
       
  
    server = ia;
    theSocket = ds;
    
  
Methods Summary
public voidrun()


    DataInputStream userInput;
    String theLine;
    DatagramPacket theOutput;

    try {
      userInput = new DataInputStream(System.in);
      while (true) {
        theLine = userInput.readLine();
        if (theLine.equals(".")) break;
        byte[] data = new byte[theLine.length()];
        theLine.getBytes(0, theLine.length(), data, 0);
        theOutput = new DatagramPacket(data, data.length, server, echoPort);
        theSocket.send(theOutput);
        Thread.yield();
      }
      eot.stop();
    }  // end try
    catch (IOException e) {
      System.err.println(e);
    }