From 8a3cc16d5370bbf35c6ce5e42a52bc344a00a89b Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 16 Dec 2017 19:01:40 +0000 Subject: [PATCH] Small fix --- src/Socket.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Socket.php b/src/Socket.php index 9cadce14..738c8c74 100644 --- a/src/Socket.php +++ b/src/Socket.php @@ -24,6 +24,11 @@ if (!extension_loaded('pthreads')) { $this->sock = socket_create($domain, $type, $protocol); } + public function __destruct() + { + socket_close($this->sock); + } + public function setOption(int $level, int $name, $value) { if (in_array($name, [\SO_RCVTIMEO, \SO_SNDTIMEO])) { @@ -129,6 +134,9 @@ if (!extension_loaded('pthreads')) { { $this->protocol = getprotobynumber($protocol); } + public function __destruct() { + if ($this->sock !== NULL) fclose($this->sock); + } public function setOption(int $level, int $name, $value) {