Package java.nio.channels

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


            ch.configureBlocking(blocking);
        } catch (IOException e) {
            LOG.error("Failed to open SocketChannel.", e);
            throw new IllegalStateException(e);
        }
        final Socket sock = ch.socket();
        if(rcvbufSize != -1) {
            try {
                sock.setReceiveBufferSize(rcvbufSize);
            } catch (SocketException e) {
                LOG.error("Failed to setReceiveBufferSize.", e);
View Full Code Here

    writeBuffer.clear();
    readBuffer.clear();
    readBuffer.flip();
    try {
      SocketChannel socketChannel = selector.provider().openSocketChannel();
      Socket socket = socketChannel.socket();
      socket.setTcpNoDelay(true);
      socket.setTrafficClass(IPTOS_LOWDELAY);
      socket.connect(remoteAddress, timeout); // Connect using blocking mode for simplicity.
      socketChannel.configureBlocking(false);
      this.socketChannel = socketChannel;
View Full Code Here

      selectionKey = socketChannel.register(selector, SelectionKey.OP_READ);
      selectionKey.attach(this);

      if (DEBUG) {
        debug("kryonet", "Port " + socketChannel.socket().getLocalPort() + "/TCP connected to: "
          + socketChannel.socket().getRemoteSocketAddress());
      }

      lastReadTime = lastWriteTime = System.currentTimeMillis();
    } catch (IOException ex) {
View Full Code Here

      selectionKey = socketChannel.register(selector, SelectionKey.OP_READ);
      selectionKey.attach(this);

      if (DEBUG) {
        debug("kryonet", "Port " + socketChannel.socket().getLocalPort() + "/TCP connected to: "
          + socketChannel.socket().getRemoteSocketAddress());
      }

      lastReadTime = lastWriteTime = System.currentTimeMillis();
    } catch (IOException ex) {
      close();
View Full Code Here

    SocketChannel  channel = ((TCPTransportHelper)filter.getHelper()).getSocketChannel();
      
    //set advanced socket options
    try {
      int so_sndbuf_size = COConfigurationManager.getIntParameter( "network.tcp.socket.SO_SNDBUF" );
      if( so_sndbuf_size > 0 channel.socket().setSendBufferSize( so_sndbuf_size );
     
      String ip_tos = COConfigurationManager.getStringParameter( "network.tcp.socket.IPDiffServ" );
      if( ip_tos.length() > 0 channel.socket().setTrafficClass( Integer.decode( ip_tos ).intValue() );
    }
    catch( Throwable t ) {
View Full Code Here

    try {
      int so_sndbuf_size = COConfigurationManager.getIntParameter( "network.tcp.socket.SO_SNDBUF" );
      if( so_sndbuf_size > 0 channel.socket().setSendBufferSize( so_sndbuf_size );
     
      String ip_tos = COConfigurationManager.getStringParameter( "network.tcp.socket.IPDiffServ" );
      if( ip_tos.length() > 0 channel.socket().setTrafficClass( Integer.decode( ip_tos ).intValue() );
    }
    catch( Throwable t ) {
      t.printStackTrace();
    }
   
View Full Code Here

    }
    catch( Throwable t ) {
      t.printStackTrace();
    }
   
  InetSocketAddress tcp_address = new InetSocketAddress( channel.socket().getInetAddress(), channel.socket().getPort());

  ConnectionEndpoint  co_ep = new ConnectionEndpoint(tcp_address);

  ProtocolEndpointTCP  pe_tcp = (ProtocolEndpointTCP)ProtocolEndpointFactory.createEndpoint( ProtocolEndpoint.PROTOCOL_TCP, co_ep, tcp_address );
View Full Code Here

    }
    catch( Throwable t ) {
      t.printStackTrace();
    }
   
  InetSocketAddress tcp_address = new InetSocketAddress( channel.socket().getInetAddress(), channel.socket().getPort());

  ConnectionEndpoint  co_ep = new ConnectionEndpoint(tcp_address);

  ProtocolEndpointTCP  pe_tcp = (ProtocolEndpointTCP)ProtocolEndpointFactory.createEndpoint( ProtocolEndpoint.PROTOCOL_TCP, co_ep, tcp_address );
View Full Code Here

    }
   
    try{
      SocketChannel  channel = getSocketChannel();
     
      channel.socket().setSendBufferSize( size_in_bytes );
      channel.socket().setReceiveBufferSize( size_in_bytes );
     
      int snd_real = channel.socket().getSendBufferSize();
      int rcv_real = channel.socket().getReceiveBufferSize();
     
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.