Added checks

This commit is contained in:
Shoghi Cervantes Pueyo 2013-03-09 12:40:53 +01:00
parent 8bf4b5cafa
commit 84ac13d591
2 changed files with 9 additions and 2 deletions

View File

@ -35,4 +35,5 @@ require_once(FILE_PATH."/src/dependencies.php");
$server = new ServerAPI();
$server->run();
kill(getmypid()); //Fix for segfault

View File

@ -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));
}