Package java.net

Examples of java.net.ServerSocket.bind()


      String address = bindToTokenList.get(serverSocketIndex);
      try {
        ServerSocket serverSocket = createServerSocket();
        addr = new InetSocketAddress(address, port);
        serverSocket.setReuseAddress(true);
        serverSocket.bind(addr);
        Acceptor acceptor = new Acceptor(serverSocket);
        try {
          acceptor.setSoTimeout(timeout);
        } catch (SocketException e) {
          Logger.error(this, "Unable to setSoTimeout in setBindTo() on "+addr);
View Full Code Here


   {
      // find an unused ehpemeral port
      InetSocketAddress inetSocketAddress = new InetSocketAddress(InetAddress.getLocalHost(), 0);
      ServerSocket serverSocket = new ServerSocket();
      serverSocket.setReuseAddress(true); // this allows the server port to be bound to even if it's in TIME_WAIT
      serverSocket.bind(inetSocketAddress);
      port = serverSocket.getLocalPort();
      serverSocket.close();
      return port;
   }
View Full Code Here

        String v = props.getProperty(ADDRESS_PROPERTY);
        InetAddress address = v == null ? null : InetAddress.getByName(v);
        int port = Integer.parseInt(props.getProperty(PORT_PROPERTY, "0"));

        InetSocketAddress socketAddress = new InetSocketAddress(address, port);
        socket.bind(socketAddress);

        Main.log("Started server listening on " + socket.getLocalSocketAddress() + ":"
            + socket.getLocalPort());

        accept = new Thread(new Runnable()
View Full Code Here

        this.configure(false);

        final ServerSocket server;
        try {
            server = new ServerSocket();
            server.bind(this.socketAddress);
            writePortToConfigFile(getConfigFile(),
                new InetSocketAddress(server.getInetAddress(), server.getLocalPort()), this.secretKey);
            Thread.currentThread().setName(
                "Apache Sling Control Listener@" + server.getInetAddress() + ":" + server.getLocalPort());
            Main.info("Apache Sling Control Listener started", null);
View Full Code Here

        ClasspathBuilder classpath = new ClasspathBuilder().add(standaloneServerJar);
        JVMBuilder vmb = new JVMBuilder();
        vmb.systemProperties(properties);

        ServerSocket serverSocket = new ServerSocket();
        serverSocket.bind(new InetSocketAddress("localhost", 0));
        serverSocket.setSoTimeout(10000);

        // use -cp + FQCN instead of -jar since remoting.jar can be rebundled
        // (like in the case of the swarm plugin.)
        vmb.classpath().addJarOf(Channel.class);
View Full Code Here

    int socketWriteTimeout = conf.getInt("dfs.datanode.socket.write.timeout",
        HdfsConstants.WRITE_TIMEOUT);
   
    ServerSocket ss = (socketWriteTimeout > 0) ?
        ServerSocketChannel.open().socket() : new ServerSocket();
    ss.bind(socAddr, 0);
   
    // Check that we got the port we need
    if(ss.getLocalPort() != socAddr.getPort())
      throw new RuntimeException("Unable to bind on specified streaming port in secure " +
          "context. Needed " + socAddr.getPort() + ", got " + ss.getLocalPort());
View Full Code Here

            // open a channel and bind
            ServerSocketChannel serverChannel = ServerSocketChannel.open();
            ServerSocket serverSocket = serverChannel.socket();
            serverSocket.setReuseAddress(false); // fix for Apple JVM bug 3922515
            InetSocketAddress listenAddress = new InetSocketAddress(listenPort);
            serverSocket.bind(listenAddress);
           
            // prepare for non-blocking, selectable IO
            serverChannel.configureBlocking(false);
            serverChannel.register(connectionManager.getNIODaemon().getSelector(), SelectionKey.OP_ACCEPT);
            connectionManager.getNIODaemon().setServer(connectionManager);
View Full Code Here

    public void listen(InetAddress localEp) throws IOException
    {       
        ServerSocketChannel serverChannel = ServerSocketChannel.open();
        final ServerSocket ss = serverChannel.socket();
        ss.setReuseAddress(true);
        ss.bind(new InetSocketAddress(localEp, DatabaseDescriptor.getStoragePort()));
        socketThread = new SocketThread(ss, "ACCEPT-" + localEp);
        socketThread.start();
        listenGate.signalAll();
    }
View Full Code Here

        try
        {
            ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
            serverSocketChannel.configureBlocking(false);
            ServerSocket serverSocket = serverSocketChannel.socket();
            serverSocket.bind(new InetSocketAddress(host, port));
            return createListener(serverSocketChannel, context);
        }
        catch (ClosedChannelException e)
        {
            e.printStackTrace()// TODO - Implement
View Full Code Here

        ServerSocket ss = null;
        Socket socket = null;

        try {
            ss = new ServerSocket();
            ss.bind(bindAddress);
            socket = new Socket();

            // Timeout is set to 10 seconds in case of infinite blocking
            // on some platform.
            socket.connect(new InetSocketAddress(connectAddress, ss
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.