Entity velocity

This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-19 12:41:53 +01:00
parent 0fa3dded89
commit aef32f2012
3 changed files with 22 additions and 26 deletions

View file

@ -30,29 +30,22 @@ the Free Software Foundation, either version 3 of the License, or
class UDPSocket{
private $encrypt;
var $buffer, $connected, $errors, $sock, $server;
function __construct($server, $port, $listen = false, $socket = false){
function __construct($server, $port, $listen = false){
$this->errors = array_fill(88,(125 - 88) + 1, true);
$this->server = $server;
$this->port = $port;
if($socket !== false){
$this->sock = $socket;
$this->sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($this->sock, SOL_SOCKET, SO_BROADCAST, 1); //Allow sending broadcast messages
if($listen !== true){
$this->connected = true;
$this->buffer = array();
$this->unblock();
}else{
$this->sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($this->sock, SOL_SOCKET, SO_BROADCAST, 1);
if($listen !== true){
$this->connected = true;
$this->buffer = array();
if(socket_bind($this->sock, "0.0.0.0", $port) === true){
$this->unblock();
}else{
if(socket_bind($this->sock, "0.0.0.0", $port) === true){
$this->unblock();
}else{
console("[ERROR] Couldn't bind to 0.0.0.0:".$port, true, true, 0);
die();
}
console("[ERROR] Couldn't bind to 0.0.0.0:".$port, true, true, 0);
die();
}
}
}