Examples of socket()


Examples of java.nio.channels.ServerSocketChannel.socket()

   
    public NioSocketServer(boolean useNIO) throws IOException {
        if (useNIO) {
            ServerSocketChannel ssc = ServerSocketChannel.open();
            ssc.configureBlocking(false);
            ServerSocket ss = ssc.socket();
            ss.bind(new InetSocketAddress(LISTEN_PORT));
           
            this.selector = Selector.open();
            ssc.register(this.selector, SelectionKey.OP_ACCEPT);
        } else {
View Full Code Here

Examples of java.nio.channels.ServerSocketChannel.socket()

        try
        {
            channel = ServerSocketChannel.open();
            channel.configureBlocking( false );
            channel.socket().setReuseAddress( true );
            InetSocketAddress address = new InetSocketAddress( _serverInfo.getInterface(), _serverInfo.getPort() );
            channel.socket().bind( address, 1024 );
            this._serverInfo.setHost( address.getHostName() + ':' + address.getPort() );
            // this._connectionHeader.setChannel(channel);
            for ( int i = 0; i < processors.length; i++ )
View Full Code Here

Examples of java.nio.channels.ServerSocketChannel.socket()

        {
            channel = ServerSocketChannel.open();
            channel.configureBlocking( false );
            channel.socket().setReuseAddress( true );
            InetSocketAddress address = new InetSocketAddress( _serverInfo.getInterface(), _serverInfo.getPort() );
            channel.socket().bind( address, 1024 );
            this._serverInfo.setHost( address.getHostName() + ':' + address.getPort() );
            // this._connectionHeader.setChannel(channel);
            for ( int i = 0; i < processors.length; i++ )
            {
                processors[i] = new CombinedConnectionProcessor( this._serverInfo );
View Full Code Here

Examples of java.nio.channels.ServerSocketChannel.socket()

        EJServerRegistry.getInstance().register( this );

        if ( logger.isLoggable( Level.INFO ) )
        {
            logger.log( Level.INFO, "EJOE server listening on: " + channel.socket().getLocalSocketAddress() );
            logger.log( Level.INFO, "Using " + processors.length + " Connection Processor"
                    + (processors.length > 1 ? "s" : "") );
            logger.log( Level.INFO, "Using non-blocking IO: " + this._serverInfo.hasNonBlockingReadWrite() );
            logger.log( Level.INFO, "Allowing persistent client connections: " + this._serverInfo.isPersistent() );
            logger.log( Level.INFO, "Using compression: " + this._serverInfo.hasCompression() );
View Full Code Here

Examples of java.nio.channels.ServerSocketChannel.socket()

      manager.setMonitor( monitor );
      manager.setSoTimeout( 10 );
      final String name = "name";
      assertEquals( "isConnected pre connect", false, manager.isConnected( name ) );
      final ServerSocketChannel channel = ServerSocketChannel.open();
      final ServerSocket serverSocket = channel.socket();
      serverSocket.setReuseAddress( true );
      final InetAddress localAddress = InetAddress.getLocalHost();
      final Random random = new Random();
      final int port = Math.abs( random.nextInt() % 5000 ) + 1024;
      final InetSocketAddress address = new InetSocketAddress( localAddress, port );
View Full Code Here

Examples of java.nio.channels.ServerSocketChannel.socket()

                    }
                }
                if ((key.readyOps() & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT)
                {
                    ServerSocketChannel ch = (ServerSocketChannel)key.channel();
                    java.net.ServerSocket ss = (java.net.ServerSocket)ch.socket();
                    Socket s = (Socket)key.attachment();
                    if (s != null)
                    {
//                        System.out.println(s + ": OnRead(ACCEPT)");
                        s.OnRead(); // ListenSocket.OnRead will call OnAccept on new Socket
View Full Code Here

Examples of java.nio.channels.ServerSocketChannel.socket()

                    }
                }
                if ((key.readyOps() & SelectionKey.OP_CONNECT) == SelectionKey.OP_CONNECT)
                {
                    SocketChannel ch = (SocketChannel)key.channel();
                    java.net.Socket ss = (java.net.Socket)ch.socket();
                    Socket s = (Socket)key.attachment();
                    if (s != null)
                    {
//                        System.out.println(s + ": OnConnect");
                        ch.finishConnect();
View Full Code Here

Examples of java.nio.channels.ServerSocketChannel.socket()

            // Set it to non-blocking, so we can use select
            ssc.configureBlocking( false );
           
            // Get the Socket connected to this channel, and bind it
            // to the listening port
            ServerSocket ss = ssc.socket();
            InetSocketAddress isa = new InetSocketAddress( port );
            ss.bind( isa );
           
            attach(ssc);
            return 0;
View Full Code Here

Examples of java.nio.channels.ServerSocketChannel.socket()

    public void OnRead()
    {
        try
        {
            ServerSocketChannel ssc = (ServerSocketChannel)GetChannel();
            java.net.ServerSocket ss = (java.net.ServerSocket)ssc.socket();
            // It's an incoming connection.
            // Register this socket with the Selector
            // so we can listen for input on it
            try
            {
View Full Code Here

Examples of java.nio.channels.SocketChannel.socket()

                return;
            }
            ServerSocketChannel serverChannel = (ServerSocketChannel) key.channel();
            SocketChannel socketChannel = serverChannel.accept();
            if(LOG.isDebugEnabled()) {
                LOG.debug("accepted a connection from " + socketChannel.socket().getInetAddress());
            }
            socketChannel.configureBlocking(false);
            socketChannel.register(key.selector(), SelectionKey.OP_READ, nextHandler);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.