001 import java.io.*;
002 import java.net.*;
003
004 /**
005 * Hello World Client.
006 * Generates clientside socket to host and port sends given message.
007 * @author Heinz Kredel.
008 */
009 public class HelloWorldClient {
010
011 static int port = 40000;
012 static String host = "localhost";
013 static String msg = "Hallo Welt";
014
015 /**
016 * @param args hostname message
017 */
018 public static void main(String[] args) {
019
020 if (args.length > 0) host = args[0];
021 if (args.length > 1) msg = args[1];
022
023 Integer x = new Integer(4711);
024
025 try {
026 Socket s = new Socket( host, port );
027 System.out.println("Client connected to Server");
028
029 SocketChannel c = new SocketChannel(s);
030
031 c.send( msg );
032 c.send( x );
033
034 c.close();
035
036 } catch (IOException e) {
037 System.out.println("IOException "+e);
038 }
039
040 }
041
042
043 }