Package java.net

Examples of java.net.ServerSocket.bind()


                str = m_comSocket.getLocalAddress().getHostAddress();

            socket = new ServerSocket();
            socket.setReuseAddress(true);
            if (port > 0)
                socket.bind(new InetSocketAddress("0.0.0.0", port));
            else
                socket.bind(null);
            socket.setSoTimeout(m_activeTimeOut);

            port = socket.getLocalPort();
View Full Code Here


            socket = new ServerSocket();
            socket.setReuseAddress(true);
            if (port > 0)
                socket.bind(new InetSocketAddress("0.0.0.0", port));
            else
                socket.bind(null);
            socket.setSoTimeout(m_activeTimeOut);

            port = socket.getLocalPort();
            str = str.replace('.', ',');
            str += ',';
View Full Code Here

           
            // Get the Socket connected to this channel, and bind it
            // to the listening port
            ServerSocket ss = ssc.socket();
            InetSocketAddress isa = new InetSocketAddress( port );
            ss.bind( isa );
           
            attach(ssc);
            return 0;
        } catch (java.io.IOException e)
        {
View Full Code Here

        conf = new Configuration(args[0]);
        if(conf.isDebug()) {
            System.err.println("Starting server with port " + conf.getPort() + " and key " + conf.getKey());
        }
        ServerSocket server = new ServerSocket();
        server.bind(new InetSocketAddress(InetAddress.getLocalHost(),conf.getPort()));
        while(true) {
            Thread t1 = new Thread(new Handler(server.accept()));
            t1.setDaemon(true);
            t1.start();
        }
View Full Code Here

        NioTcpClient client = new NioTcpClient();
        client.setConnectTimeoutMillis(1000);

        ServerSocket server = new ServerSocket();
        try {
            server.bind(null);
            IoFuture<IoSession> cf = client.connect(new InetSocketAddress("localhost", server.getLocalPort()));
            Thread.sleep(5000);
            IoSession session = cf.get();
            System.err.println(session);
            Assert.fail();
View Full Code Here

    public void generate_all_kind_of_client_event() throws IOException, InterruptedException, ExecutionException {
        NioTcpClient client = new NioTcpClient();
        client.setFilters(new MyCodec(), new Handler());

        ServerSocket serverSocket = new ServerSocket();
        serverSocket.bind(null);
        int port = serverSocket.getLocalPort();

        // warm up
        Thread.sleep(100);
        final long t0 = System.currentTimeMillis();
View Full Code Here

        } else {
            ssock = new ServerSocket();
        }
       
        ssock.setReuseAddress(true); // probably pointless for port '0'
        ssock.bind(TEST_SERVER_ADDR);
        servicedSocket = ssock;

        listenerThread = new Thread(new RequestListener());
        listenerThread.setDaemon(false);
        listenerThread.start();
View Full Code Here

     */
    public void run() {
        ServerSocket server = null;
        try {
            server = new ServerSocket();
            server.bind(socketAddress);
            log.info("Sling Control Server started on " + socketAddress.toString());
        } catch (IOException ioe) {
            log.error("Failed to start Sling Control Server", ioe);
            return;
        }
View Full Code Here

        // 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
        serverChannel.configureBlocking (false);
        // register the ServerSocketChannel with the Selector
        serverChannel.register (selector, SelectionKey.OP_ACCEPT);
        while (doListen) {
View Full Code Here

            throw new IllegalStateException("Unable to create ServerSocket.", ex);
        }

        try {
            InetSocketAddress sa = new InetSocketAddress(port);
            serverSocket.bind(sa);
            return true;
        }
        catch (IOException ex) {
            return false;
        }
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.