import java.net.*; import java.io.*; public class echoInputThread extends Thread { InetAddress server; int echoPort = 7; DatagramSocket theSocket; public echoInputThread(InetAddress ia, DatagramSocket ds) { server = ia; theSocket = ds; } public void run() { 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(); } } // end try catch (IOException e) { System.err.println(e); } } // end run }