Code example for ServerSocketChannel

Methods: configureBlocking, socket

0
    /* ------------------------------------------------------------ */ 
    public void open() throws IOException 
    { 
        // Create a new server socket and set to non blocking mode 
        _acceptChannel= ServerSocketChannel.open();
        _acceptChannel.configureBlocking(true);
 
        // Bind the server socket to the local host and port 
        InetSocketAddress addr = getHost()==null?new InetSocketAddress(getPort()):new InetSocketAddress(getHost(),getPort());
        _acceptChannel.socket().bind(addr,getAcceptQueueSize());
    } 
 
    /* ------------------------------------------------------------ */ 
    public void close() throws IOException 
    { 
        if (_acceptChannel != null)
            _acceptChannel.close();
        _acceptChannel=null;
    } 
     
    /* ------------------------------------------------------------ */