function connect() { $this->_connection = fsockopen('udp://' . $this->_ip, $this->_port, $error['number'], $error['string']); if($this->_connection) { fwrite($this->_connection, $this->_command_status); stream_set_timeout($this->_connection, $this->_timeout, 0); stream_set_blocking($this->_connection, true); $this->_data = fgetc($this->_connection); $status = stream_get_meta_data($this->_connection); if($status['timed_out']) { $this->_status = false; return false; } else { if($status['unread_bytes'] > 0) { $this->_data .= fread($this->_connection, $status['unread_bytes']); } else { $this->_status = false; return false; } } } else { $this->_status = false; return false; } return fclose($this->_connection); }