mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
Added checks
This commit is contained in:
parent
8bf4b5cafa
commit
84ac13d591
2 changed files with 9 additions and 2 deletions
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue