import java.net.*; //Defines socket-related classes import java.io.*; //Defines stream-related classes public class Connection extends Thread { private Socket clientSocket; private PrintWriter pOut; //This class allows ordinary file IO over the socket DataOutputStream output; //For using writeUTF public Connection(Socket aClientSocket) { clientSocket = aClientSocket; } public void run() { try { // Create a new PrintWriter with automatic flushing; // getOutputStream returns an OutputStream object pOut = new PrintWriter(clientSocket.getOutputStream(), true); // now send a message to the client pOut.println("The Date and Time is " + new java.util.Date().toString()); //output = new DataOutputStream(clientSocket.getOutputStream()); //output.writeUTF("The Date and Time is " + new java.util.Date().toString()); clientSocket.close(); } catch (java.io.IOException e) {System.out.println("Connection:"+e.getMessage());} } }