Accepts a new connection from the socket.

@param socket the socket connection structure

@return true if the accept returns a new socket.
351574
@Override
  public boolean accept(SocketBar socket)
    throws IOException
  {
    JniSocketImpl jniSocket = (JniSocketImpl) socket;

    if (_fd == 0)
      throw new IOException("accept from closed socket");

    return jniSocket.accept(this, _fd, _socketTimeout);
  }
966900
def accept(self):
        """"""
        socket = Socket(self._llc, None)
        socket._tco = self.llc.accept(self._tco)
        return socket
544958
public void setSocket(Socket socket) throws IOException {
        if (this.socket != null) {
            this.socket.close();
            this.socket = null;
        }
        this.socket = socket;
        setTimeout(timeout);
        prepareStreams(socket);
    }
442596
private void doSocketConnect(InetSocketAddress addr) throws IOException{
        SocketChannel sock = createSock();
        registerAndConnect(sock, addr);
    }
1288670
private void replaceSocket(Socket newSocket) {
        synchronized (m_socketLock) {
            closeSocket(m_socket);
            if (m_eos.get()) {
                closeSocket(newSocket);
                m_socket = null;
            } else {
                m_socket = newSocket;
            }
        }
    }
457085
public static boolean isPortAvailable(String host, int port) {
        try {
            Socket socket = new Socket(host, port);
            socket.close();
            return false;
        } catch (IOException e) {
            return true;
        }
    }
1213122
public boolean bind ()
    {
        // open our TCP listening ports
        int successes = 0;
        for (int port : _ports) {
            try {
                acceptConnections(port);
                successes++;
            } catch (IOException ioe) {
                log.warning("Failure listening to socket", "hostname", _bindHostname,
                            "port", port, ioe);
            }
        }
        return successes > 0;
    }
1031294
public function acceptTcp($main_socket) {
        $socket = @stream_socket_accept($main_socket, 0, $remote_address);
        
        //thundering herd EAGAIN (Resource temporarily unavailable)
        if (!$socket) {
            return;
        }
        
        $connection = new Connection($socket, $this);
        
        if($this->handler ){
            $this->handler->attach($connection);
        }
        
        $this->handler->owner = $this;
        
        $this->trigger(Server::ON_ACCEPT, new IOEvent(['context'=>$connection]));
        
        $connection->ready();
    }
887361
def client_socket(self, config):
		
		if self.__client_socket is None:
			self.__client_socket = self.create_client_socket(config)
		return self.__client_socket
996690
public static boolean closeClientSocket(final Socket clientSocket)
	{
		boolean closed = true;
		try
		{
			close(clientSocket);
		}
		catch (final IOException e)
		{
			LOGGER.error("IOException occured by trying to close the client socket.", e);
			closed = false;
		}
		finally
		{
			try
			{
				close(clientSocket);
			}
			catch (final IOException e)
			{
				LOGGER.error("IOException occured by trying to close the client socket.", e);
				closed = false;
			}
		}
		return closed;
	}
219670
public void handleConnection(Socket socket)
        throws IOException
    {
        HttpConnection connection = createConnection(socket);
        
        try
        {
            if (_lowResourcePersistTimeMs>0 && isLowOnResources())
            {
                socket.setSoTimeout(_lowResourcePersistTimeMs);
                connection.setThrottled(true);
            }
            else
            {
                socket.setSoTimeout(getMaxIdleTimeMs());
                connection.setThrottled(false);
            }
            
        }
        catch(Exception e)
        {
            log.warn(LogSupport.EXCEPTION,e);
        }

        connection.handle();
    }
1079105
public function acceptUdpConnection($socket)
    {
        set_error_handler(function(){});
        $recv_buffer = stream_socket_recvfrom($socket, static::MAX_UDP_PACKAGE_SIZE, 0, $remote_address);
        restore_error_handler();
        if (false === $recv_buffer || empty($remote_address)) {
            return false;
        }
        // UdpConnection.
        $connection           = new UdpConnection($socket, $remote_address);
        $connection->protocol = $this->protocol;
        if ($this->onMessage) {
            try {
                if ($this->protocol !== null) {
                    /** @var \Workerman\Protocols\ProtocolInterface $parser */
                    $parser      = $this->protocol;
                    if(method_exists($parser,'input')){
                        while($recv_buffer !== ''){
                            $len = $parser::input($recv_buffer, $connection);
                            if($len == 0)
                                return true;
                            $package = substr($recv_buffer,0,$len);
                            $recv_buffer = substr($recv_buffer,$len);
                            $data = $parser::decode($package,$connection);
                            if ($data === false)
                                continue;
                            call_user_func($this->onMessage, $connection, $data);
                        }
                    }else{
                        $data = $parser::decode($recv_buffer, $connection);
                        // Discard bad packets.
                        if ($data === false)
                            return true;
                        call_user_func($this->onMessage, $connection, $data);
                    }
                }else{
                    call_user_func($this->onMessage, $connection, $recv_buffer);
                }
                ConnectionInterface::$statistics['total_request']++;
            } catch (\Exception $e) {
                static::log($e);
                exit(250);
            } catch (\Error $e) {
                static::log($e);
                exit(250);
            }
        }
        return true;
    }
1304616
@Override
	public ServerSocket createServerSocket(int port) throws IOException
    {
    	ServerSocket socket = getSocketFactory().createServerSocket(port,backLog,getListenAddress());
    	if (manageSockets)
    		createdSockets.add(socket);
    	return socket;
    }
1291724
private boolean acceptStream(
            int streamId, byte priority, boolean remoteSideClosed, boolean localSideClosed) {
        // Cannot initiate any new streams after receiving or sending GOAWAY
        if (receivedGoAwayFrame || sentGoAwayFrame) {
            return false;
        }

        boolean remote = isRemoteInitiatedId(streamId);
        int maxConcurrentStreams = remote ? localConcurrentStreams : remoteConcurrentStreams;
        if (spdySession.numActiveStreams(remote) >= maxConcurrentStreams) {
            return false;
        }
        spdySession.acceptStream(
                streamId, priority, remoteSideClosed, localSideClosed,
                initialSendWindowSize, initialReceiveWindowSize, remote);
        if (remote) {
            lastGoodStreamId = streamId;
        }
        return true;
    }
458469
private StateConnection accept()
  {
    try {
      _state = StateHttpEnum.READ;
      
      //_requestHttp = _connHttp.newRequestHttp();

      _invocation = (InvocationBaratine) _requestHttp.parseInvocation();
      
      if (_invocation == null) {
        _state = StateHttpEnum.CLOSE;
        
        
        _state = _state.toIdle();
        
        if (connHttp().request() == this) {
          connHttp().requestComplete(this, false);
          //connHttp().protocol().requestFree(this);
          return StateConnection.CLOSE;
        }
        else {
          //connHttp().protocol().requestFree(this);
          return StateConnection.READ;
        }
      }
      
      // sequence used for write ordering 
       //_sequenceRead = connHttp().nextSequenceRead();
      
      if (_state.isBodyComplete()) {
        bodyComplete();
      }
      else if (! requestHttp().isUpgrade()) {
        _requestHttp.readBodyChunk();
      }
      
      _invocation.service(this);
      
      //ServiceRef.flushOutboxAndExecuteLast();
      ServiceRef.flushOutbox();
      
      if (! _state.isBodyComplete()) {
        return StateConnection.READ;
      }
      else if (_state == StateHttpEnum.UPGRADE) {
        return StateConnection.READ;
      }
      else if (_requestHttp.isKeepalive()) {
        return StateConnection.READ;
      }
      else {
        return StateConnection.CLOSE_READ_A;
      }
    } catch (Throwable e) {
      log.warning(e.toString());
      log.log(Level.FINER, e.toString(), e);
      
      //e.printStackTrace();
      
      //toClose();
      
      return StateConnection.CLOSE;
    }
  }
180386
@Override
    public void handle(final ServerWebSocket socket) {
        LOGGER.info("New web socket connection {}, {}", socket, socket.uri());

        if (! configuration.accept(socket.uri())) {
            LOGGER.warn("Web Socket connection denied on {} by {}", socket.uri(), configuration.name());
            return;
        }

        final Socket sock = new Socket(socket);
        accessor.getDispatcher().addSocket(socket.path(), sock);

        socket.closeHandler(event -> {
            LOGGER.info("Web Socket closed {}, {}", socket, socket.uri());
            accessor.getDispatcher().removeSocket(socket.path(), sock);
        });

        socket.handler(event -> accessor.getDispatcher().received(socket.path(), event.getBytes(), sock));

    }
790808
def _accept(self, listen_socket):
        
        conn, addr = listen_socket.accept()
        connection = TelnetConnection(conn, addr, self.application, self, encoding=self.encoding)
        self.connections.add(connection)

        logger.info('New connection %r %r', *addr)