Code example for ServerSocketChannel

Methods: accept, close, socket

0
         */ 
        protected SourceChannelImpl(SelectorProvider provider)
                throws IOException { 
            super(provider);
            sourceServer = provider.openServerSocketChannel();
            sourceServer.socket().bind(
                new InetSocketAddress(InetAddress.getByName(null), 0));
            serverPort = sourceServer.socket().getLocalPort();
        } 
 
        void closeServer() throws IOException { 
            sourceServer.close();
        } 
 
        void accept() throws IOException { 
            sourceSocket = (SocketChannelImpl) sourceServer.accept();
        } 
 
        protected void implCloseSelectableChannel() throws IOException { 
            sourceSocket.close();
        }