1 8 package phoenixdemo.client; 9 10 import java.io.IOException ; 11 import java.io.ObjectOutputStream ; 12 import java.net.Socket ; 13 14 18 public class Client 19 { 20 public static void main( final String [] args ) 21 throws IOException 22 { 23 if( args.length < 3 ) 24 { 25 System.out.println( "Usage java -jar pdkdemo-client.jar <hostname> <port> <message>" ); 26 System.exit( 10 ); 27 } 28 29 final String host = args[ 0 ]; 30 final int port = Integer.parseInt( args[ 1 ] ); 31 final String message = args[ 2 ]; 32 final Socket socket = new Socket ( host, port ); 33 final ObjectOutputStream oos = new ObjectOutputStream ( socket.getOutputStream() ); 34 35 oos.writeObject( message ); 36 oos.close(); 37 socket.close(); 38 } 39 } 40 | Popular Tags |