/** * @param resource $socket The socket to wrap * @throws Exceptions\SocketException */ public function __construct($socket) { // check for proper resource if (!\is_resource($socket)) { throw SocketException::invalidSocketGiven(); } $this->socket = $socket; // create socket id if (true === @\socket_getpeername($this->socket, $addr, $port)) { $this->id = "{$addr}:{$port}"; } else { $this->id = 'unknown'; } }