diff --git a/src/GameQ/Query/Native.php b/src/GameQ/Query/Native.php index af65884e..7073ddba 100644 --- a/src/GameQ/Query/Native.php +++ b/src/GameQ/Query/Native.php @@ -59,8 +59,16 @@ public function write($data) $this->create(); } + if (!is_resource($this->socket)) { + throw new Exception('Socket is not a valid resource'); + } + // Send the packet - return fwrite($this->socket, $data); + $bytes = @fwrite($this->socket, $data); + if ($bytes === false) { + throw new Exception('Failed to write to socket'); + } + return $bytes; } catch (\Exception $e) { throw new Exception($e->getMessage(), $e->getCode(), $e); } diff --git a/src/GameQ/Server.php b/src/GameQ/Server.php index fd1dca76..702e0c86 100644 --- a/src/GameQ/Server.php +++ b/src/GameQ/Server.php @@ -322,7 +322,7 @@ public function getJoinLink() } // Fill the template to build the final joinLink - return sprintf($joinLink, $this->ip, $this->portClient()); + return !isset($this->join_link) ? '' : sprintf($joinLink, $this->ip, $this->portClient()); } // Socket holding