Package java.net

Examples of java.net.ServerSocket


    public String getName() {
        return endpointName;
    }

    protected ServerSocket createSocket( int port ) throws IOException {
        ServerSocket socket = factory.createServerSocket( port );
        return socket;
    }
View Full Code Here


 
    throws IOException
  {
    error_listener  = _error_listener;
   
    server_socket = new ServerSocket( 0, 50, InetAddress.getByName( "127.0.0.1" ));
   
    new AEThread2( "TranscodePipe", true )
    {
      public void
      run()
View Full Code Here

   * @param forceRemoteIndex force the thread to use a {@link RemoteIndex} instead
   * of a {@link RemoteBitStreamIndex}, even if the latter would be usable.
   */

  public static void start( final Index index, final InetAddress address, final int port, boolean forceRemoteIndex ) throws IOException {
    start( index, new ServerSocket( port, 0, address ), forceRemoteIndex );
  }
View Full Code Here

        this.key = key;
        this.servers = servers;
        this.kill = kill;
        setDaemon(true);
        setName("StopJettyPluginMonitor");
        serverSocket = new ServerSocket(port, 1, InetAddress.getByName("127.0.0.1"));
        serverSocket.setReuseAddress(true);
    }
View Full Code Here

     *
     * @throws IOException
     */
    public static int findFreePort(int initPort) throws IOException {
        int port = -1;
        ServerSocket tmpSocket = null;
        // first try the default port
        try {
            tmpSocket = new ServerSocket(initPort);

            port = initPort;
           
            System.out.println("Using default port: " + port);
        } catch (IOException e) {
            System.out.println("Failed to use specified port");
            // didn't work, try to find one dynamically
            try {
                int attempts = 0;

                while (port < 1024 && attempts < 2000) {
                    attempts++;

                    tmpSocket = new ServerSocket(0);

                    port = tmpSocket.getLocalPort();
                }

            } catch (IOException e1) {
                throw new IOException(
                        "Failed to find a port to use for testing: "
                                + e1.getMessage());
            }
        } finally {
            if (tmpSocket != null) {
                try {
                    tmpSocket.close();
                } catch (IOException e) {
                    // ignore
                }
                tmpSocket = null;
            }
View Full Code Here

            InetAddress bindAddress = getBindAddress();
            if (ssl) {
                return CipherFactory.createServerSocket(port, bindAddress);
            }
            if (bindAddress == null) {
                return new ServerSocket(port);
            }
            return new ServerSocket(port, 0, bindAddress);
        } catch (BindException be) {
            throw DbException.get(ErrorCode.EXCEPTION_OPENING_PORT_2,
                    be, "" + port, be.toString());
        } catch (IOException e) {
            throw DbException.convertIOException(e, "port: " + port + " ssl: " + ssl);
View Full Code Here

    /**
     * @return binded sock address
     */
    public InetSocketAddress setup() throws IOException {
        ServerSocket servSocket = serverChannel.socket();
        servSocket.setReuseAddress(true);
        InetSocketAddress sockaddr = NetUtils.getAnyLocalInetSocketAddress();
        servSocket.bind(sockaddr);
        return sockaddr;
    }
View Full Code Here

        servSocket.bind(sockaddr);
        return sockaddr;
    }

    public void setup(int port) throws IOException {
        ServerSocket servSocket = serverChannel.socket();
        servSocket.setReuseAddress(true);
        InetAddress addr = NetUtils.getLocalHost(false);
        InetSocketAddress sockaddr = new InetSocketAddress(addr, port);
        servSocket.bind(sockaddr);
    }
View Full Code Here

     * @return the port we opened or -1 if we couldn't open one.
   */
   private int connect()
   {
       try {
           serverSocket = new ServerSocket(0);
           return serverSocket.getLocalPort();
       } catch (IOException e) {
           logger.error( "Could not listen on port: " + port, e );
           return -1;
       }
View Full Code Here

 
  public void run()
  {
    try {
      int count = 0;
      ServerSocket serversocket  = new ServerSocket(_port);
      serversocket.setSoTimeout(2000);
      anvil.Log.log().info("Admininstration end point created at "+_port);
      while(_listen) {
        try {
          Socket socket = serversocket.accept();
          TelnetAdminClient adminclient = new TelnetAdminClient(socket);
          adminclient.setName("Admin-"+(count++));
          adminclient.start();
        } catch (InterruptedIOException e) {
        }
      }
     
      serversocket.close();
     
    } catch (Throwable t) {
      anvil.Log.log().error(t);   
    }
  }
View Full Code Here

TOP

Related Classes of java.net.ServerSocket

Copyright © 2018 www.massapicom. 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.