Package java.nio.channels

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


            }

            // 2. Create a ServerSocketChannel
            sock_channel=ServerSocketChannel.open();
            sock_channel.configureBlocking(false);
            sock_channel.socket().bind(key);

            // 3. Register the selector with all server sockets. 'Key' is attachment, so we get it again on
            //    select(). That way we can associate it with the mappings hashmap to find the corresponding
            //    value
            sock_channel.register(selector, SelectionKey.OP_ACCEPT, key);
View Full Code Here


          ServerSocketChannel channel = ServerSocketChannel.open();
         
          try
          {
            channel.configureBlocking(false);
            channel.socket().bind(new InetSocketAddress(anyLocalAddressIPv6, 0));
            Logger.log(new LogEvent(LOGID, "NetworkAdmin: testing nio + ipv6 bind successful"));

            supportsIPv6withNIO = true;
          } catch (Exception e)
          {
View Full Code Here

      ServerSocketChannel ssc = null;
     
      try{
        ssc = ServerSocketChannel.open();
     
        ssc.socket().bind( new InetSocketAddress(bind_ip,0), 16 );
       
        return( true );
       
      }catch( Throwable e ){
       
View Full Code Here

      ServerSocketChannel ssc = null;
     
      try{
        ssc = ServerSocketChannel.open();

        ssc.socket().setReuseAddress( true );
       
        bind( ssc, null, port );

        port = ssc.socket().getLocalPort();
       
View Full Code Here

        ssc.socket().setReuseAddress( true );
       
        bind( ssc, null, port );

        port = ssc.socket().getLocalPort();
       
        ssc.close();
       
        return( port );
       
View Full Code Here

        ServerSocketChannel serverSocket;
        URI localAddress;
        try {
            serverSocket = ServerSocketChannel.open();
            serverSockets.add(serverSocket);
            serverSocket.socket().bind(new InetSocketAddress(0));
            localAddress = new URI(String.format("tcp://localhost:%d", serverSocket.socket().getLocalPort()));
            LOGGER.debug("Listening on {}.", localAddress);
        } catch (Exception e) {
            throw UncheckedException.asUncheckedException(e);
        }
View Full Code Here

        URI localAddress;
        try {
            serverSocket = ServerSocketChannel.open();
            serverSockets.add(serverSocket);
            serverSocket.socket().bind(new InetSocketAddress(0));
            localAddress = new URI(String.format("tcp://localhost:%d", serverSocket.socket().getLocalPort()));
            LOGGER.debug("Listening on {}.", localAddress);
        } catch (Exception e) {
            throw UncheckedException.asUncheckedException(e);
        }
View Full Code Here

   
    try{
     
      final ServerSocketChannel  ssc = ServerSocketChannel.open();
     
      ServerSocket ss  = ssc.socket();
     
      ss.setReuseAddress(true);

      ss.bindnew InetSocketAddress( InetAddress.getByName("127.0.0.1"), port), 128 );
     
View Full Code Here

   
    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

        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

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.