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