Package java.nio.channels

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


      CharsetDecoder decoder = charset.newDecoder();
      // Create the server socket channel
      ServerSocketChannel serverSocketChannel = ServerSocketChannel
          .open();
      // nonblocking I/O
      serverSocketChannel.configureBlocking(false);
      // host-port 7935
      serverSocketChannel.socket().bind(new java.net.InetSocketAddress(KorusRuntime.getJavaPort()));
      // Create the selector
      Selector selector = Selector.open();
      // Recording server to selector (type OP_ACCEPT)
View Full Code Here


        while ((request = this.requestQueue.poll()) != null) {
            SocketAddress address = request.getAddress();
            ServerSocketChannel serverChannel;
            try {
                serverChannel = ServerSocketChannel.open();
                serverChannel.configureBlocking(false);
            } catch (IOException ex) {
                throw new IOReactorException("Failure opening server socket", ex);
            }
            try {
                serverChannel.socket().bind(address);
View Full Code Here

      } // end of try-catch
    } // end of for ()
    InetSocketAddress isa = null;
    while ((isa = waiting_accept.poll()) != null) {
      ServerSocketChannel ssc = ServerSocketChannel.open();
      ssc.configureBlocking(false);
      ssc.socket().bind(isa);
      ssc.register(clientSel, SelectionKey.OP_ACCEPT, null);
    } // end of while (isa = waiting_accept.poll() != null)
  }
View Full Code Here

    switch (al.getConnectionType()) {
    case accept:
      log.finest("Setting up 'accept' channel...");
      ServerSocketChannel ssc = ServerSocketChannel.open();
      ssc.socket().setReceiveBufferSize(RECEIVE_BUFFER_SIZE);
      ssc.configureBlocking(false);
      ssc.socket().bind(isa);
      ssc.register(selector, SelectionKey.OP_ACCEPT, al);
      break;
    case connect:
      log.finest("Setting up 'connect' channel for: "
View Full Code Here

       
        boolean success = false;
       
        try {
            // This is a non blocking socket channel
            channel.configureBlocking(false);
       
            // Configure the server socket,
            ServerSocket socket = channel.socket();
           
            // Set the reuseAddress flag accordingly with the setting
View Full Code Here

    public void listen(EndPoint localEp) throws IOException
    {       
        ServerSocketChannel serverChannel = ServerSocketChannel.open();
        ServerSocket ss = serverChannel.socket();           
        ss.bind(localEp.getInetAddress());
        serverChannel.configureBlocking(false);
       
        SelectionKeyHandler handler = new TcpConnectionHandler(localEp);

        SelectionKey key = SelectorManager.getSelectorManager().register(serverChannel, handler, SelectionKey.OP_ACCEPT);         
        endPoints_.add(localEp);           
View Full Code Here

        ServerSocketChannel serverChannel = ServerSocketChannel.open();

        ServerSocket serverSocket = serverChannel.socket();
        InetSocketAddress address = new InetSocketAddress(host, port);
        serverSocket.bind(address);
        serverChannel.configureBlocking(false);

        this.port = serverSocket.getLocalPort();
        me = URI.create("conn://" + this.host + ":" + this.port);

        selector = Selector.open();
View Full Code Here

    }

    public SocketAddress listen(
            final SocketAddress address) throws IOException {
        ServerSocketChannel serverChannel = ServerSocketChannel.open();
        serverChannel.configureBlocking(false);
        serverChannel.socket().bind(address);
        SelectionKey key = serverChannel.register(this.selector, SelectionKey.OP_ACCEPT);
        key.attach(null);
        return serverChannel.socket().getLocalSocketAddress();
    }
View Full Code Here

        // create a new Selector for use below
        selector = Selector.open();
        // set the port the server channel will listen to
        serverSocket.bind (new InetSocketAddress (getBind(),getTcpListenPort()));
        // set non-blocking mode for the listening socket
        serverChannel.configureBlocking (false);
        // register the ServerSocketChannel with the Selector
        serverChannel.register (selector, SelectionKey.OP_ACCEPT);
        while (doListen && selector != null) {
            // this may block for a long time, upon return the
            // selected set contains keys of the ready channels
View Full Code Here

            return;
        }
        if (maxPort < startPort)
            maxPort = startPort;
        ServerSocketChannel ssc = ServerSocketChannel.open();
        ssc.configureBlocking(false);
        for( int i=startPort; i<=maxPort; i++ ) {
            try {
                InetSocketAddress iddr = null;
                if( inet == null ) {
                    iddr = new InetSocketAddress( 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.