From 4f6fa13155b0ca86fa98c5b3c58160caae80ffcc Mon Sep 17 00:00:00 2001 From: SeekDaSky Date: Thu, 7 Dec 2017 15:35:07 +0100 Subject: [PATCH] fix: Interop not closing socket + discard keepalive packets --- build/kwebsocket/core/wsinterop.php | 10 +++++++++- build/router/controller/page.php | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/build/kwebsocket/core/wsinterop.php b/build/kwebsocket/core/wsinterop.php index c3224ff..5eaf3d0 100644 --- a/build/kwebsocket/core/wsinterop.php +++ b/build/kwebsocket/core/wsinterop.php @@ -35,7 +35,10 @@ } public function receive() : array{ - $size = unpack("N",socket_read($this->socket,4))[1]; + $size = 0; + while($size == 0){ + $size = unpack("N",socket_read($this->socket,4))[1]; + } $read = 0; $data = ""; $tmp = ""; @@ -51,4 +54,9 @@ return json_decode($data,true); } + public function close(){ + socket_shutdown($this->socket); + socket_close($this->socket); + } + } \ No newline at end of file diff --git a/build/router/controller/page.php b/build/router/controller/page.php index a4963b0..00339d2 100755 --- a/build/router/controller/page.php +++ b/build/router/controller/page.php @@ -60,6 +60,7 @@ $_SESSION['NAME'] = $check['name']; } + $wsi->close(); $wsi = null; }