Package java.nio.channels

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


          // if isAccetable = true
          // then a MemcacheClient required a connection
          if (key.isAcceptable())
          {
            // get MemcacheClient socket channel
            SocketChannel client = serverSocketChannel.accept();
            // Non Blocking I/O
            client.configureBlocking(false);
            // recording to the selector (reading)
            client.register(selector, SelectionKey.OP_READ);
            continue;
View Full Code Here


            if (key.isAcceptable()) {

                ServerSocketChannel serverChannel = (ServerSocketChannel) key.channel();
                SocketChannel socketChannel = null;
                try {
                    socketChannel = serverChannel.accept();
                } catch (IOException ex) {
                    if (this.exceptionHandler == null ||
                            !this.exceptionHandler.handle(ex)) {
                        throw new IOReactorException(
                                "Failure accepting connection", ex);
View Full Code Here

    void doAccept(SelectionKey key) throws IOException, OutOfMemoryError {
      Connection c;
      ServerSocketChannel server = (ServerSocketChannel) key.channel();

      SocketChannel channel;
      while ((channel = server.accept()) != null) {
        try {
          channel.configureBlocking(false);
          channel.socket().setTcpNoDelay(tcpNoDelay);
          channel.socket().setKeepAlive(tcpKeepAlive);
        } catch (IOException ioe) {
View Full Code Here

        for (Iterator i = clientSel.selectedKeys().iterator(); i.hasNext();) {
          SelectionKey sk = (SelectionKey)i.next();
          i.remove();
          if ((sk.readyOps() & SelectionKey.OP_ACCEPT) != 0) {
            ServerSocketChannel nextReady = (ServerSocketChannel)sk.channel();
            SocketChannel sc = nextReady.accept();
            log.finer("Registered new client socket: "+sc);
            handler.handleSocketAccept(sc);
          }
          if ((sk.readyOps() & SelectionKey.OP_CONNECT) != 0) {
            // Not implemented yet
View Full Code Here

          SelectionKey sk = (SelectionKey)i.next();
          i.remove();
          SocketChannel sc = null;
          if ((sk.readyOps() & SelectionKey.OP_ACCEPT) != 0) {
            ServerSocketChannel nextReady = (ServerSocketChannel)sk.channel();
            sc = nextReady.accept();
            log.finest("OP_ACCEPT");
          } // end of if (sk.readyOps() & SelectionKey.OP_ACCEPT)
          if ((sk.readyOps() & SelectionKey.OP_CONNECT) != 0) {
            sk.cancel();
            sc = (SocketChannel)sk.channel();
View Full Code Here

                while (it.hasNext()) {
                    SelectionKey key = (SelectionKey) it.next();
                    // Is a new connection coming in?
                    if (key.isAcceptable()) {
                        ServerSocketChannel server = (ServerSocketChannel) key.channel();
                        SocketChannel channel = server.accept();
                        channel.socket().setReceiveBufferSize(getRxBufSize());
                        channel.socket().setSendBufferSize(getTxBufSize());
                        channel.socket().setTcpNoDelay(getTcpNoDelay());
                        channel.socket().setKeepAlive(getSoKeepAlive());
                        channel.socket().setOOBInline(getOoBInline());
View Full Code Here

                while (it!=null && it.hasNext()) {
                    SelectionKey key = it.next();
                    // Is a new connection coming in?
                    if (key.isAcceptable()) {
                        ServerSocketChannel server = (ServerSocketChannel) key.channel();
                        SocketChannel channel = server.accept();
                        channel.socket().setReceiveBufferSize(getTxBufSize());
                        channel.socket().setSendBufferSize(getTxBufSize());
                        channel.socket().setTcpNoDelay(getTcpNoDelay());
                        channel.socket().setKeepAlive(getSoKeepAlive());
                        channel.socket().setOOBInline(getOoBInline());
View Full Code Here

    void doAccept(SelectionKey key) throws IOException, OutOfMemoryError {
      Connection c;
      ServerSocketChannel server = (ServerSocketChannel) key.channel();

      SocketChannel channel;
      while ((channel = server.accept()) != null) {
        channel.configureBlocking(false);
        channel.socket().setTcpNoDelay(tcpNoDelay);
        channel.socket().setKeepAlive(tcpKeepAlive);

        Reader reader = getReader();
View Full Code Here

    void doAccept(SelectionKey key) throws IOException, OutOfMemoryError {
      Connection c;
      ServerSocketChannel server = (ServerSocketChannel) key.channel();

      SocketChannel channel;
      while ((channel = server.accept()) != null) {
        channel.configureBlocking(false);
        channel.socket().setTcpNoDelay(tcpNoDelay);
        channel.socket().setKeepAlive(tcpKeepAlive);

        Reader reader = getReader();
View Full Code Here

    }

    void doAccept(SelectionKey key) throws IOException,  OutOfMemoryError {
      Connection c = null;
      ServerSocketChannel server = (ServerSocketChannel) key.channel();
      SocketChannel channel = server.accept();
      channel.configureBlocking(false);
      SelectionKey readKey = channel.register(selector, SelectionKey.OP_READ);
      c = new Connection(readKey, channel, System.currentTimeMillis());
      readKey.attach(c);
      synchronized (connectionList) {
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.