diff --git a/mqtt/SocketClient.php b/mqtt/SocketClient.php index 40aa206..171f58f 100644 --- a/mqtt/SocketClient.php +++ b/mqtt/SocketClient.php @@ -162,8 +162,13 @@ public function set_non_blocking() public function write($packet, $packet_size) { if (!$this->socket || !is_resource($this->socket)) return false; + Debug::Log(Debug::DEBUG, "socket_write(length={$packet_size})", $packet); - return fwrite($this->socket, $packet, $packet_size); + + do { $packet = substr($packet, fwrite($this->socket, $packet)); } while (!empty($packet)); + + If (!empty($packet)) {return false;} else {return $packet_size;} + } /** @@ -229,4 +234,4 @@ public function select($timeout) } } -# EOF \ No newline at end of file +# EOF