Package java.nio.channels

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


                serverChannel = ServerSocketChannel.open();
            } catch (final IOException ex) {
                throw new IOReactorException("Failure opening server socket", ex);
            }
            try {
                final ServerSocket socket = serverChannel.socket();
                socket.setReuseAddress(this.config.isSoReuseAddress());
                serverChannel.configureBlocking(false);
                socket.bind(address);
            } catch (final IOException ex) {
                closeChannel(serverChannel);
View Full Code Here


                throw new IOReactorException("Failure registering channel " +
                        "with the selector", ex);
            }

            this.endpoints.add(request);
            request.completed(serverChannel.socket().getLocalSocketAddress());
        }
    }

    public Set<ListenerEndpoint> getEndpoints() {
        final Set<ListenerEndpoint> set = new HashSet<ListenerEndpoint>();
View Full Code Here

     * @param localEp InetAddress whose port to listen on.
     */
    public void listen(InetAddress localEp) throws IOException
    {       
        ServerSocketChannel serverChannel = ServerSocketChannel.open();
        ServerSocket ss = serverChannel.socket();
        ss.bind(new InetSocketAddress(localEp, DatabaseDescriptor.getStoragePort()));
        serverChannel.configureBlocking(false);
       
        SelectionKeyHandler handler = new TcpConnectionHandler(localEp);

View Full Code Here

                else
                {
                    cfg = ( SocketAcceptorConfig ) getDefaultConfig();
                }

                ssc.socket().setReuseAddress( cfg.isReuseAddress() );
                ssc.socket().setReceiveBufferSize(
                    ( ( SocketSessionConfig ) cfg.getSessionConfig() ).getReceiveBufferSize() );

                // and bind.
                ssc.socket().bind( req.address, cfg.getBacklog() );
View Full Code Here

                {
                    cfg = ( SocketAcceptorConfig ) getDefaultConfig();
                }

                ssc.socket().setReuseAddress( cfg.isReuseAddress() );
                ssc.socket().setReceiveBufferSize(
                    ( ( SocketSessionConfig ) cfg.getSessionConfig() ).getReceiveBufferSize() );

                // and bind.
                ssc.socket().bind( req.address, cfg.getBacklog() );
                if( req.address == null || req.address.getPort() == 0 )
View Full Code Here

                ssc.socket().setReuseAddress( cfg.isReuseAddress() );
                ssc.socket().setReceiveBufferSize(
                    ( ( SocketSessionConfig ) cfg.getSessionConfig() ).getReceiveBufferSize() );

                // and bind.
                ssc.socket().bind( req.address, cfg.getBacklog() );
                if( req.address == null || req.address.getPort() == 0 )
                {
                    req.address = ( InetSocketAddress ) ssc.socket().getLocalSocketAddress();
                }
                ssc.register( selector, SelectionKey.OP_ACCEPT, req );
View Full Code Here

  public AcceptHandler newAcceptHandler( InetSocketAddress addr, int backlog,
    AcceptHandlerFactory factory ) throws Exception
  {
    ServerSocketChannel ssc = ServerSocketChannel.open();
    ssc.configureBlocking( false );
    ServerSocket ss = ssc.socket();
    ss.bind( addr, backlog );
    AcceptHandler ah = factory.newAcceptHandler( ssc );
    register( ah );
    return ah;
  }
View Full Code Here

            }
            catch (IOException e)
            {
                throw new RuntimeException(e);
            }
            ServerSocket socket = serverChannel.socket();
            try
            {
                socket.setReuseAddress(true);
            }
            catch (SocketException e)
View Full Code Here

                // Open a channel.
                ch = ServerSocketChannel.open();

                // Configure the channel
                try {
                    ch.socket().bind(new InetSocketAddress(0));
                    ch.configureBlocking(false);
                } catch (IOException e) {
                    logger.warn("Failed to configure a temporary socket.", e);
                    return -1;
                }
View Full Code Here

     */
    public void test_finishConnect() throws Exception {
        SocketAddress address = new InetSocketAddress("localhost", 0);

        ServerSocketChannel theServerChannel = ServerSocketChannel.open();
        ServerSocket serversocket = theServerChannel.socket();
        serversocket.setReuseAddress(true);
        // Bind the socket
        serversocket.bind(address);

        boolean doneNonBlockingConnect = false;
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.