LdapTools\Utilities\TcpSocket::connect PHP Метод

connect() публичный Метод

Connect to the host on the port defined for this TCP socket.
public connect ( string $host, integer $port, integer $timeout = 1 ) : boolean
$host string
$port integer
$timeout integer
Результат boolean
    public function connect($host, $port, $timeout = 1)
    {
        $this->socket = @stream_socket_client("tcp://{$host}:{$port}", $errorNumber, $errorMessage, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($this->options));
        return (bool) $this->socket;
    }

Usage Example

Пример #1
0
 /**
  * Check if a LDAP server is up and available.
  *
  * @param string $server
  * @return bool
  */
 protected function isServerAvailable($server)
 {
     $result = $this->tcp->connect($server, $this->config->getPort(), $this->config->getConnectTimeout());
     if ($result) {
         $this->tcp->close();
     }
     return $result;
 }
All Usage Examples Of LdapTools\Utilities\TcpSocket::connect