diff --git a/PocketMine-MP.php b/PocketMine-MP.php index e901cc209..521ad8eae 100644 --- a/PocketMine-MP.php +++ b/PocketMine-MP.php @@ -35,4 +35,5 @@ require_once(FILE_PATH."/src/dependencies.php"); $server = new ServerAPI(); $server->run(); + kill(getmypid()); //Fix for segfault diff --git a/src/network/UDPSocket.php b/src/network/UDPSocket.php index 9c65f3d70..007378edb 100644 --- a/src/network/UDPSocket.php +++ b/src/network/UDPSocket.php @@ -77,13 +77,19 @@ class UDPSocket{ } public function read(){ + if($this->connected === false){ + return false; + } $source = false; - $port = 1; - $len = @socket_recvfrom($this->sock, $buf, 65536, 0, $source, $port); + $port = 1; //$source and $port will be overwritten + $len = @socket_recvfrom($this->sock, $buf, 65535, 0, $source, $port); return array($buf, $source, $port, $len); } public function write($data, $dest = false, $port = false){ + if($this->connected === false){ + return false; + } return @socket_sendto($this->sock, $data, strlen($data), 0, ($dest === false ? $this->server:$dest), ($port === false ? $this->port:$port)); }