import java.net.Socket; import java.net.SocketException; import java.io.*; public class TCPEchoClient{ public static void main( String args[]) throws IOException{ Socket sc = new Socket( args[0], 24000); InputStream in = sc.getInputStream(); OutputStream out = sc.getOutputStream(); byte[] data= args[1].getBytes(); out.write(data); int bytesRecvd = in.read( data, 0, data.length ); if( bytesRecvd == -1) throw new SocketException("Connection closed prematurely"); System.out.println("Received: " + new String(data)); sc.close(); } }