//SimpClient.java //send command line message to server import java.net.*; import java.io.*; public class SimpClient { public static void main( String[] args ) throws IOException, ClassNotFoundException { Socket client; //for convenience of send/receive objects, primitives: ObjectInputStream input; ObjectOutputStream output; String message; //String serverName = "127.0.0.1"; //localhost String serverName = "192.168.0.197"; //make connection attempt to IP, port client = new Socket( InetAddress.getByName( serverName ), 12345 ); System.out.println( "Client made connection to: " + client.getInetAddress().getHostName() ); //output stream for objects output = new ObjectOutputStream( client.getOutputStream() ); output.flush(); input = new ObjectInputStream( client.getInputStream() ); //client will send first message = args[0]; output.writeObject( message ); output.flush(); //? //then receive message = (String)input.readObject(); System.out.println( "Client received: " + message ); input.close(); output.close(); } }