ip = $ip; $this->port = $port; // todo: if local network connect use AF_UNIX $this->sock = \socket_create(AF_INET, SOCK_STREAM, SOL_TCP); } /** * Destructor. * * @since 1.0.0 */ public function __destruct() { $this->close(); } /** * {@inheritdoc} */ public function close() { if ($this->sock !== null) { socket_shutdown($this->sock, 2); socket_close($this->sock); $this->sock = null; } } }