KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > phoenixdemo > client > Client


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE.txt file.
7  */

8 package phoenixdemo.client;
9
10 import java.io.IOException JavaDoc;
11 import java.io.ObjectOutputStream JavaDoc;
12 import java.net.Socket JavaDoc;
13
14 /**
15  * @author Paul Hammant <a HREF="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
16  * @version $Revision: 1.4 $
17  */

18 public class Client
19 {
20     public static void main( final String JavaDoc[] args )
21         throws IOException JavaDoc
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 JavaDoc host = args[ 0 ];
30         final int port = Integer.parseInt( args[ 1 ] );
31         final String JavaDoc message = args[ 2 ];
32         final Socket JavaDoc socket = new Socket JavaDoc( host, port );
33         final ObjectOutputStream JavaDoc oos = new ObjectOutputStream JavaDoc( socket.getOutputStream() );
34
35         oos.writeObject( message );
36         oos.close();
37         socket.close();
38     }
39 }
40
Popular Tags