Package java.nio.channels

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


    {
        doListen = true;
        // allocate an unbound server socket channel
        ServerSocketChannel serverChannel = ServerSocketChannel.open();
        // Get the associated ServerSocket to bind it with
        ServerSocket serverSocket = serverChannel.socket();
        // create a new Selector for use below
        selector = Selector.open();
        // set the port the server channel will listen to
        serverSocket.bind (new InetSocketAddress (bind,tcpListenPort));
        // set non-blocking mode for the listening socket
View Full Code Here


     * @param localEp InetAddress whose port to listen on.
     */
    public void listen(InetAddress localEp) throws IOException
    {       
        ServerSocketChannel serverChannel = ServerSocketChannel.open();
        ServerSocket ss = serverChannel.socket();
        ss.bind(new InetSocketAddress(localEp, DatabaseDescriptor.getStoragePort()));
        serverChannel.configureBlocking(false);
       
        SelectionKeyHandler handler = new TcpConnectionHandler(localEp);

View Full Code Here

        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
        ServerSocket socket = serverChannel.socket();
        try
        {
            socket.setReuseAddress(true);
        }
        catch (SocketException e)
View Full Code Here

            logger_.info("Starting Encrypted Messaging Service on port {}", DatabaseDescriptor.getStoragePort());
        }
        else
        {
            ServerSocketChannel serverChannel = ServerSocketChannel.open();
            ss = serverChannel.socket();
            ss.setReuseAddress(true);
            InetSocketAddress address = new InetSocketAddress(localEp, DatabaseDescriptor.getStoragePort());
            try
            {
                ss.bind(address);
View Full Code Here

                    cfg = (SocketAcceptorConfig) req.config;
                } else {
                    cfg = getDefaultConfig();
                }

                ssc.socket().setReuseAddress(cfg.isReuseAddress());
                ssc.socket().setReceiveBufferSize(
                        cfg.getSessionConfig().getReceiveBufferSize());

                // and bind.
                ssc.socket().bind(req.address, cfg.getBacklog());
View Full Code Here

                } else {
                    cfg = getDefaultConfig();
                }

                ssc.socket().setReuseAddress(cfg.isReuseAddress());
                ssc.socket().setReceiveBufferSize(
                        cfg.getSessionConfig().getReceiveBufferSize());

                // and bind.
                ssc.socket().bind(req.address, cfg.getBacklog());
                if (req.address == null || req.address.getPort() == 0) {
View Full Code Here

                ssc.socket().setReuseAddress(cfg.isReuseAddress());
                ssc.socket().setReceiveBufferSize(
                        cfg.getSessionConfig().getReceiveBufferSize());

                // and bind.
                ssc.socket().bind(req.address, cfg.getBacklog());
                if (req.address == null || req.address.getPort() == 0) {
                    req.address = (InetSocketAddress) ssc.socket()
                            .getLocalSocketAddress();
                }
                ssc.register(selector, SelectionKey.OP_ACCEPT, req);
View Full Code Here

                        cfg.getSessionConfig().getReceiveBufferSize());

                // and bind.
                ssc.socket().bind(req.address, cfg.getBacklog());
                if (req.address == null || req.address.getPort() == 0) {
                    req.address = (InetSocketAddress) ssc.socket()
                            .getLocalSocketAddress();
                }
                ssc.register(selector, SelectionKey.OP_ACCEPT, req);

                channels.put(req.address, ssc);
View Full Code Here

     * @param localEp InetAddress whose port to listen on.
     */
    public void listen(InetAddress localEp) throws IOException
    {       
        ServerSocketChannel serverChannel = ServerSocketChannel.open();
        ServerSocket ss = serverChannel.socket();
        ss.bind(new InetSocketAddress(localEp, DatabaseDescriptor.getStoragePort()));
        serverChannel.configureBlocking(false);
       
        SelectionKeyHandler handler = new TcpConnectionHandler(localEp);

View Full Code Here

            try
            {
                ssc = ServerSocketChannel.open();
                ssc.configureBlocking( false );
                ssc.socket().bind( req.address, req.backlog );
                ssc.register( selector, SelectionKey.OP_ACCEPT, req );

                channels.put( req.address, ssc );
            }
            catch( IOException e )
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.