1 87 package org.codehaus.loom.demos.distributed.client; 88 89 import java.io.IOException ; 90 import java.io.ObjectOutputStream ; 91 import java.net.Socket ; 92 93 96 public class Client 97 { 98 public static void main( final String [] args ) 99 throws IOException 100 { 101 if( args.length < 3 ) 102 { 103 System.out.println( 104 "Usage java -jar client.jar <hostname> <port> <message>" ); 105 System.exit( 10 ); 106 } 107 108 final String host = args[ 0 ]; 109 final int port = Integer.parseInt( args[ 1 ] ); 110 final String message = args[ 2 ]; 111 final Socket socket = new Socket ( host, port ); 112 final ObjectOutputStream oos = new ObjectOutputStream ( 113 socket.getOutputStream() ); 114 115 oos.writeObject( message ); 116 oos.close(); 117 socket.close(); 118 } 119 } 120 | Popular Tags |