Code example for ServerSocket

Methods: bind, setReuseAddress

0
 
  /** 
   * Creates just a port listening server socket 
   */ 
  public TNonblockingServerSocket(int port, int clientTimeout) throws TTransportException {
    this(new InetSocketAddress(port), clientTimeout);
    port_ = port;
  }   
 
  public TNonblockingServerSocket(InetSocketAddress bindAddr) throws TTransportException {
    this(bindAddr, 0);
  } 
 
  public TNonblockingServerSocket(InetSocketAddress bindAddr, int clientTimeout) throws TTransportException {
    clientTimeout_ = clientTimeout;
    try { 
      serverSocketChannel = ServerSocketChannel.open();
      serverSocketChannel.configureBlocking(false);
 
      // Make server socket 
      serverSocket_ = serverSocketChannel.socket();