/** * Check a username/password pair. * * @param string $username username with which to authenticate * @param string $password password with which to authenticate * @return bool indicates correct or incorrect password */ function checkPassword($username, $password) { if (is_array($this->srv->connector)) { if ($this->srv->connector['timeout'] == '') { $timeout = 15; } else { $timeout = $this->srv->connector['timeout']; } $sp = fsockopen($this->srv->connector['host'], $this->srv->connector['port'], $error_number, $error_string, $timeout); $this->info = "<b>Imap Session</b><br>"; if ($sp) { socket_set_timeout($sp, $timeout); $ret = TRUE; $this->banner = fgets($sp, 1024); // Check compatibilities in here // Identifies the user $ret = $this->query($sp, 'LOGIN "' . quoteIMAP($username) . '" "' . quoteIMAP($password) . '"'); $this->query($sp, 'LOGOUT'); } else { $this->info = 'Could not connect.'; $ret = FALSE; } } else { $ret = FALSE; } return $ret; }
/** * 获取请求的响应 * @public * @return <WebResponse> http请求的响应信息 */ public function getResponse() { if (!($fp = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout))) { switch ($errno) { case -3: $this->errormsg = 'Socket连接创建失败 (-3)'; break; case -4: $this->errormsg = 'DNS定位失败 (-4)'; break; case -5: $this->errormsg = '连接超时或被拒绝 (-5)'; break; default: $this->errormsg = '连接失败 (' . $errno . ')'; break; $this->errormsg .= ' ' . $errstr; } return false; } else { } socket_set_timeout($fp, $this->timeout); $request = $this->buildRequestInfo(); fwrite($fp, $request); $content = ''; $readState = 'start'; $response = new WebResponse(); while (!feof($fp)) { $line = fgets($fp, 4096); if ($readState == 'start') { $readState = 'header'; if (!preg_match('/HTTP\\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) { $this->errormsg = "非法的请求状态: " . htmlentities($line); return false; } $http_version = $m[1]; //未使用 $response->setStatus($m[2]); $status_string = $m[3]; //未使用 } else { if ($readState == 'header') { if (trim($line) == '') { $readState = 'content'; } if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) { continue; } $key = strtolower(trim($m[1])); $val = trim($m[2]); $response->appendHeader($key, $val); } else { $content .= $line; } } } fclose($fp); $response->setContent($content); return $response; }
function connect($params = array()) { #if ( !isset( $this->status ) ) #{ # $obj = new eZClusterSMTP( $params ); # if( $obj->connect() ) # { # $obj->status = SMTP_STATUS_CONNECTED; # } # return $obj; #} #else #{ # ... #} $this->connection = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout); if (function_exists('socket_set_timeout')) { @socket_set_timeout($this->connection, 5, 0); } $greeting = $this->get_data(); if (is_resource($this->connection)) { return $this->auth ? $this->ehlo() : $this->helo(); } else { $this->errors[] = 'Failed to connect to server: ' . $errstr; return false; } }
/** * @access private * @param resource $link * @param Account $account * @param CLog $log * @return bool */ function Connect(&$link, &$account, &$log) { $setings =& Settings::CreateInstance(); if ($account->MailProtocol == MAILPROTOCOL_WMSERVER) { } else { $outHost = strlen($account->MailOutHost) > 0 ? $account->MailOutHost : $account->MailIncHost; $errno = $errstr = null; $log->WriteLine('[Connecting to server ' . $outHost . ' on port ' . $account->MailOutPort . ']'); $isSsl = strlen($outHost) > 6 && strtolower(substr($outHost, 0, 6)) == 'ssl://'; if (function_exists('openssl_open') && ($isSsl || $account->MailOutPort == 465)) { if (!$isSsl) { $outHost = 'ssl://' . $outHost; } } else { if ($isSsl) { $outHost = substr($outHost, 6); } } $link = @fsockopen($outHost, $account->MailOutPort, $errno, $errstr, 10); if (!$link) { setGlobalError('SMTP Error: ' . $errstr); $log->WriteLine(getGlobalError()); return false; } else { @socket_set_timeout($link, 10); return CSmtp::IsSuccess($link, $log); } } }
function connect($host, $username, $password) { // connect $fp = fsockopen($host, 5038, $errno, $errstr, 10); if (!$fp) { return FALSE; } else { $buffer = ''; if (version_compare(phpversion(), '4.3', '>=')) { stream_set_timeout($fp, 5); } else { socket_set_timeout($fp, 5); } $buffer = fgets($fp); if (!preg_match('/Asterisk Call Manager/i', $buffer)) { $_SESSION['ari_error'] = _("Asterisk Call Manager not responding") . "<br />\n"; return FALSE; } else { $out = "Action: Login\r\nUsername: "******"\r\nSecret: " . $password . "\r\n\r\n"; fwrite($fp, $out); $buffer = fgets($fp); if ($buffer != "Response: Success\r\n") { $_SESSION['ari_error'] = _("Asterisk authentication failed:") . "<br />" . $buffer . "<br />\n"; return FALSE; } else { $buffers = fgets($fp); // get rid of Message: Authentication accepted // connected $this->socket = $fp; } } } return TRUE; }
function SetOptions() { socket_set_option($this->Socket, SOL_SOCKET, SO_KEEPALIVE, 0); socket_set_option($this->Socket, SOL_SOCKET, SO_REUSEADDR, 1); socket_set_timeout($this->Socket, 2); socket_set_nonblock($this->Socket); }
function _Set_Timeout(&$res, $s, $m = 0) { if (version_compare(phpversion(), '4.3.0', '<')) { return socket_set_timeout($res, $s, $m); } return stream_set_timeout($res, $s, $m); }
function pyphp_init($wsgiapp) { if (strlen($wsgiapp)) { $wsgifile = $_SERVER["SCRIPT_FILENAME"]; $sockseed = $_SERVER["SCRIPT_FILENAME"]; } else { $wsgifile = ""; $sockseed = __FILE__; } $sock = "/tmp/pyphp_" . substr(md5($sockseed), 0, 8) . ".sock"; $errno = 0; $errstr = ""; if (!($fs = fsockopen($sock, 0, $errno, $errstr))) { $pyfile = substr(__FILE__, 0, -3) . "py"; $err = 0; $pyexe = "/usr/bin/python"; $cmdline = "{$pyexe} '{$pyfile}' '{$sock}' '{$wsgifile}' '{$wsgiapp}'"; # echo "$cmdline $err $errno $errstr<br>"; system($cmdline, $err); if ($err != 0) { die("php: could not launch server.\n"); } if (!($fs = fsockopen($sock, 0))) { die("php: could not connect.\n"); } } socket_set_timeout($fs, 20); return $fs; }
/** * The only purpose of this function is to send the message to the server, read the server answer, * discard the header and return the other content * * @param string $xml_request is the xml request that will be sended to teleskill * * @return mixed the xml returned by teleskill or false if error */ function _sendXmlRequest($xml_request) { $xml_answer = false; $remote_url = Get::sett('url_checkin_teleskill'); $tmp_url = parse_url($remote_url); $post_data = urlencode('message') . '=' . urlencode($xml_request); $post_request = "POST {$remote_url} HTTP/1.0\r\n" . "Host: " . $tmp_url['host'] . "\r\n" . "User-Agent: PHP Script\r\n" . "Content-type: application/x-www-form-urlencoded\r\n" . "Content-length: " . strlen($post_data) . "\r\n" . "Connection: close\r\n\r\n" . $post_data . "\r\n\r\n"; $socket = fsockopen($tmp_url['host'], 80); if (!$socket) { return false; } socket_set_timeout($socket, _TELESKILL_STREAM_TIMEOUT); fputs($socket, $post_request); // discad header $head = fgets($socket); if (substr_count($head, "200 OK") > 0) { $hedaer_row = 0; while (!(fgets($socket) == "\r\n") && $hedaer_row < 100) { ++$hedaer_row; } if ($hedaer_row == 100) { return false; } } else { return false; } while (!feof($socket)) { $xml_answer .= fgets($socket, 4096); } fclose($socket); return $xml_answer; }
function connect($params = array()) { if (!isset($this->status)) { $obj = new smtp($params); if ($obj->connect()) { $obj->status = SMTP_STATUS_CONNECTED; } return $obj; } else { if (!empty($GLOBALS['_CFG']['smtp_ssl'])) { $this->host = "ssl://" . $this->host; } $this->connection = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout); if ($this->connection === false) { $this->errors[] = 'Access is denied.'; return false; } @socket_set_timeout($this->connection, 0, 250000); $greeting = $this->get_data(); if (is_resource($this->connection)) { $this->status = 2; return $this->auth ? $this->ehlo() : $this->helo(); } else { log_write($errstr, __FILE__, __LINE__); $this->errors[] = 'Failed to connect to server: ' . $errstr; return false; } } }
private function queryServer() { $this->socket = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout); if ($this->socket) { socket_set_timeout($this->socket, $this->timeout); $isTs3 = trim(fgets($this->socket)) == "TS3"; if (!$isTs3) { return false; } if ($this->login !== false) { if (!$this->sendCommand("login client_login_name=" . $this->login . " client_login_password="******""; $response .= $this->sendCommand("use sid=" . $this->sid); $response .= $this->sendCommand("serverinfo"); $response .= $this->sendCommand("channellist -topic -flags -voice -limits"); $response .= $this->sendCommand("clientlist -uid -away -voice -groups"); $response .= $this->sendCommand("servergrouplist"); $response .= $this->sendCommand("channelgrouplist"); fputs($this->socket, "quit\n"); fclose($this->socket); return $response; } return false; }
function Connect($host, $port = 0, $tval = 30) { $this->error = null; if ($this->connected()) { $this->error = array("error" => "Already connected to a server"); return false; } if (empty($port)) { $port = $this->SMTP_PORT; } #connect to the smtp server $this->smtp_conn = fsockopen($host, $port, $errno, $errstr, $tval); # give up after ? secs # verify we connected properly if (empty($this->smtp_conn)) { $this->error = array("error" => "Failed to connect to server", "errno" => $errno, "errstr" => $errstr); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": {$errstr} ({$errno})" . $this->CRLF; } return false; } # sometimes the SMTP server takes a little longer to respond if (substr(PHP_OS, 0, 3) != "WIN") { socket_set_timeout($this->smtp_conn, $tval, 0); } # get any announcement stuff $announce = $this->get_lines(); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; } return true; }
function connect($ip, $login, $password) { for ($ATTEMPT = 1; $ATTEMPT <= $this->attempts; $ATTEMPT++) { $this->connected = false; $this->debug('Connection attempt #' . $ATTEMPT . ' to ' . $ip . ':' . $this->port . '...'); if ($this->socket = @fsockopen($ip, $this->port, $this->error_no, $this->error_str, $this->timeout)) { socket_set_timeout($this->socket, $this->timeout); $this->write('/login'); $RESPONSE = $this->read(false); if ($RESPONSE[0] == '!done') { if (preg_match_all('/[^=]+/i', $RESPONSE[1], $MATCHES)) { if ($MATCHES[0][0] == 'ret' && strlen($MATCHES[0][1]) == 32) { $this->write('/login', false); $this->write('=name=' . $login, false); $this->write('=response=00' . md5(chr(0) . $password . pack('H*', $MATCHES[0][1]))); $RESPONSE = $this->read(false); if ($RESPONSE[0] == '!done') { $this->connected = true; break; } } } } fclose($this->socket); } sleep($this->delay); } if ($this->connected) { $this->debug('Connected...'); } else { $this->debug('Error...'); } return $this->connected; }
/** * Loads remote content using sockets. */ public function getRemoteContents($url, $timeout = 10) { $result = ""; $url = parse_url($url); if ($fs = @fsockopen($url['host'], 80)) { if (function_exists("socket_set_timeout")) { socket_set_timeout($fs, $timeout, 0); } else { if (function_exists("stream_set_timeout")) { stream_set_timeout($fs, $timeout, 0); } } $http_get_cmd = "GET " . $url['path'] . "?" . $url['query'] . " HTTP/1.0\r\n" . "Host: " . $url['host'] . "\r\n" . "Connection: Close\r\n\r\n"; fwrite($fs, $http_get_cmd); while (!feof($fs)) { $result .= @fread($fs, 40960); } fclose($fs); if (strpos($result, "404 Not Found")) { return FALSE; } else { list($headers, $body) = preg_split("/\r\n\r\n/s", $result, 2); // separate headers return $body; } } else { return FALSE; } }
function GetStatus($ip, $port, $pw) { error_reporting(0); $fp = fsockopen($ip, $port, $errno, $errstr, 1); if (!$fp) { error_reporting(E_ALL); $this->error = "{$errstr} ({$errno})"; return 0; } else { error_reporting(E_ALL); socket_set_timeout($fp, 2); fputs($fp, "GET /stats?sid=1?pass="******"&mode=viewxml HTTP/1.1\r\n"); // original --> admin.cgi?pass fputs($fp, "User-Agent: Mozilla\r\n\r\n"); while (!feof($fp)) { $this->SHOUTcastData .= fgets($fp, 512); } fclose($fp); if (stristr($this->SHOUTcastData, "HTTP/1.1 200 OK") == true) { $this->SHOUTcastData = trim(substr($this->SHOUTcastData, 58)); } else { $this->error = "Bad login"; return 0; } $xmlparser = xml_parser_create('UTF-8'); //xml_parse_into_struct($xmlparser, $this->SHOUTcastData, $this->values, $this->indexes); if (!xml_parse_into_struct($xmlparser, $this->SHOUTcastData, $this->values, $this->indexes)) { $this->error = "Unparsable XML"; return 0; } xml_parser_free($this->values); return 1; } }
public function Connect($host, $port = 0, $tval = 30) { $this->error = null; if ($this->connected()) { $this->error = array("error" => "Already connected to a server"); return false; } if (empty($port)) { $port = $this->SMTP_PORT; } $this->smtp_conn = fsockopen($host, $port, $errno, $errstr, $tval); // give up after ? secs if (empty($this->smtp_conn)) { $this->error = array("error" => "Failed to connect to server", "errno" => $errno, "errstr" => $errstr); if ($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": {$errstr} ({$errno})" . $this->CRLF; } return false; } if (substr(PHP_OS, 0, 3) != "WIN") { socket_set_timeout($this->smtp_conn, $tval, 0); } $announce = $this->get_lines(); //if(function_exists("socket_set_timeout")) // socket_set_timeout($this->smtp_conn, 0, 100000); if ($this->do_debug >= 2) { echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; } return true; }
function BVHttpClient() { global $blogvault; $sno = ""; if (array_key_exists('svrno', $_REQUEST)) { $sno = intval($_REQUEST['svrno']); if (array_key_exists('mode', $_REQUEST)) { $this->mode = $_REQUEST['mode']; } else { $this->mode = "req"; } if ($this->mode === "resp") { $blogvault->addStatus("mode", "resp"); return; } } else { $this->timeout = 5; $sno = $blogvault->getOption('bvServerId'); if (empty($sno)) { $sno = "1"; } } $this->host = "pluginapi" . $sno . ".blogvault.net"; $this->port = 80; if (array_key_exists('ssl', $_REQUEST)) { $this->port = 443; $this->host = $_REQUEST['ssl'] . "://" . $host; } if (!($this->conn = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout))) { $this->errormsg = "Cannot Open Connection to Host"; $blogvault->addStatus("httperror", "Cannot Open Connection to Host"); return; } socket_set_timeout($this->conn, $this->timeout); }
/** * Creation of the server class. * * @param string $sServer Server IP, or hostname. * @param integer $iPort Server port */ public function __construct($sServer, $iPort = 7777) { /* Fill some arrays. */ $this->aServer[0] = $sServer; $this->aServer[1] = $iPort; /* Start the connection. */ $this->rSocket = fsockopen('udp://' . $this->aServer[0], $this->aServer[1], $iError, $sError, 2); if (!$this->rSocket) { $this->aServer[4] = false; return; } socket_set_timeout($this->rSocket, 2); $sPacket = 'SAMP'; $sPacket .= chr(strtok($this->aServer[0], '.')); $sPacket .= chr(strtok('.')); $sPacket .= chr(strtok('.')); $sPacket .= chr(strtok('.')); $sPacket .= chr($this->aServer[1] & 0xff); $sPacket .= chr($this->aServer[1] >> 8 & 0xff); $sPacket .= 'p4150'; fwrite($this->rSocket, $sPacket); if (fread($this->rSocket, 10)) { if (fread($this->rSocket, 5) == 'p4150') { $this->aServer[4] = true; return; } } $this->aServer[4] = false; }
function &connect($params = array()) { if (!isset($this->status)) { $obj = new smtp($params); if ($obj->connect()) $obj->status = SMTP_STATUS_CONNECTED; return $obj; } else { $this->connection = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout); if (function_exists('socket_set_timeout')) @socket_set_timeout($this->connection, 5, 0); $greeting = $this->get_data(); if (is_resource($this->connection)) return $this->auth ? $this->ehlo() : $this->helo(); else { $this->errors[] = 'Failed to connect to server: ' . $errstr; return false; } } }
/** * AsyncPost */ public static function asyncPost($url, $param) { $bits = parse_url($url); $host = $bits['host']; $port = isset($bits['port']) ? $bits['port'] : 80; $path = isset($bits['path']) ? $bits['path'] : '/'; $method = 'POST'; $timeOut = 0.001; $paramStr = http_build_query($param); if (!($fp = @fsockopen($host, $port, $errno, $errstr, $timeOut))) { return false; } socket_set_timeout($fp, $timeOut); $headers = array(); $headers[] = $method . ' ' . $path . ' HTTP/1.0'; $headers[] = 'Host: ' . $host; $headers[] = 'Accept-language: en-us'; if ($paramStr) { $headers[] = 'Content-Type: application/x-www-form-urlencoded'; $headers[] = 'Content-Length: ' . strlen($paramStr); } $request = implode("\r\n", $headers) . "\r\n\r\n" . $paramStr; fwrite($fp, $request); return true; }
public function connect($host, $port = false, $tval = 30) { if ($this->connected) { return true; } set_error_handler(array($this, 'catchWarning')); $this->pop_conn = fsockopen($host, $port, $errno, $errstr, $tval); restore_error_handler(); if ($this->error && $this->do_debug >= 1) { $this->displayErrors(); } if ($this->pop_conn == false) { $this->error = array('error' => "Failed to connect to server {$host} on port {$port}", 'errno' => $errno, 'errstr' => $errstr); if ($this->do_debug >= 1) { $this->displayErrors(); } return false; } if (version_compare(phpversion(), '5.0.0', 'ge')) { stream_set_timeout($this->pop_conn, $tval, 0); } else { if (substr(PHP_OS, 0, 3) !== 'WIN') { socket_set_timeout($this->pop_conn, $tval, 0); } } $pop3_response = $this->getResponse(); if ($this->checkResponse($pop3_response)) { $this->connected = true; return true; } return false; }
public function connect($host, $port, $path, $origin = false) { $this->_host = $host; $this->_port = $port; $this->_path = $path; $this->_origin = $origin; $key = base64_encode($this->_generateRandomString(16, false, true)); $header = "GET " . $path . " HTTP/1.1\r\n"; $header .= "Host: " . $host . ":" . $port . "\r\n"; $header .= "Upgrade: websocket\r\n"; $header .= "Connection: Upgrade\r\n"; $header .= "Sec-WebSocket-Key: " . $key . "\r\n"; if ($origin !== false) { $header .= "Sec-WebSocket-Origin: " . $origin . "\r\n"; } $header .= "Sec-WebSocket-Version: 13\r\n"; $this->_Socket = fsockopen($host, $port, $errno, $errstr, 2); socket_set_timeout($this->_Socket, 0, 10000); @fwrite($this->_Socket, $header); $response = @fread($this->_Socket, 1500); preg_match('#Sec-WebSocket-Accept:\\s(.*)$#mU', $response, $matches); $keyAccept = trim($matches[1]); $expectedResonse = base64_encode(pack('H*', sha1($key . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'))); $this->_connected = $keyAccept === $expectedResonse ? true : false; return $this->_connected; }
function fsocketrequest($url,$method,$postdata) { //debug_zval_dump($this->port.$this->host); if(!($fp=@fsockopen($this->host,$this->port,$error,$errormsg,600))) { $this->errormsg="初始化套接字失败!"; return FALSE; } socket_set_timeout($fp,600); // debug_zval_dump($postdata); $reqdata=$this->buildrequestdata($method,$postdata); // debug_zval_dump($reqdata); if(!@fwrite($fp,$reqdata)) { $this->errormsg="请求失败!"; return FALSE; } $respone=""; while (!feof($fp)) { $respone .= fgets($fp); } if (!$respone) { $this->errormsg="服务器无应答!"; return FALSE; } $separator = '/\r\n\r\n/'; list($header, $body) = preg_split($separator, $respone, 2); return $this->converttoclientcharset($body); }
function get_http_header($target) { // URIから各情報を取得 $info = parse_url($target); $scheme = $info['scheme']; $host = $info['host']; $port = $info['port']; $path = $info['path']; // ポートが空の時はデフォルトの80にします。 if (!$port) { $port = 80; } // リクエストフィールドを制作。 $msg_req = "HEAD " . $path . " HTTP/1.0\r\n"; $msg_req .= "Host: " . $host . "\r\n"; $msg_req .= "User-Agent: H2C/1.0\r\n"; $msg_req .= "\r\n"; // スキームがHTTPの時のみ実行 if ($scheme == 'http') { $status = array(); // 指定ホストに接続。 if ($handle = @fsockopen($host, $port, $errno, $errstr, 1)) { fputs($handle, $msg_req); if (socket_set_timeout($handle, 3)) { $line = 0; while (!feof($handle)) { // 1行めはステータスライン if ($line == 0) { $temp_stat = explode(' ', fgets($handle, 4096)); $status['HTTP-Version'] = array_shift($temp_stat); $status['Status-Code'] = array_shift($temp_stat); $status['Reason-Phrase'] = implode(' ', $temp_stat); // 2行目以降はコロンで分割してそれぞれ代入 } else { $temp_stat = explode(':', fgets($handle, 4096)); $name = array_shift($temp_stat); // 通常:の後に1文字半角スペースがあるので除去 $status[$name] = substr(implode(':', $temp_stat), 1); } $line++; } } else { $status['HTTP-Version'] = '---'; $status['Status-Code'] = '902'; $status['Reason-Phrase'] = "No Response"; } fclose($handle); } else { $status['HTTP-Version'] = '---'; $status['Status-Code'] = '901'; $status['Reason-Phrase'] = "Unable To Connect"; } } else { $status['HTTP-Version'] = '---'; $status['Status-Code'] = '903'; $status['Reason-Phrase'] = "Not HTTP Request"; } return $status; }
function get_players($socket) { $challenge = $this->get_challenge($socket); $this->q_player = $this->q_player . $challenge; socket_set_timeout($socket, 3); fwrite($socket, $this->q_player); $this->s_info['player'] = fread($socket, $this->maxlen); }
/** * Open Connection to Socket Cache Server * @return Bool * @param $domain String * @param $port Float[optional] * @param $timeout Int[optional] */ function open($domain, $port = 9801, $timeout = 15) { if (($this->socket = fsockopen($domain, (double) $port)) !== false) { socket_set_timeout($this->socket, (int) $timeout); return true; } return false; }
function openSocket($server, $port) { if ($this->activeSocket = fsockopen($server, $port)) { socket_set_blocking($this->activeSocket, 0); socket_set_timeout($this->activeSocket, 31536000); return true; } return false; }
public function _connect() { $this->_socket = @pfsockopen($this->_host, $this->_port, $errno, $errstr, $this->_timeout); if ($this->_socket === false) { return new PHPTCP_Error($errno, $errstr); } stream_set_write_buffer($this->_socket, 0); socket_set_timeout($this->_socket, $this->_timeout); }
/** * Creates a new SampQuery object. * @param $server server hostname * @param $port port of the server */ public function __construct($server, $port = 7777) { // <editor-fold defaultstate="collapsed" desc="Constructor"> $this->server = $server; $this->port = $port; $this->sock = fsockopen("udp://" . $this->server, $this->port, $errorNum, $errorString, 2); socket_set_timeout($this->sock, 2); // </editor-fold> }
public function deviceOpen() { $this->_socket = @fsockopen($this->_host, $this->_port, $errno, $errstr, 30); if (!$this->_socket) { throw new Exception("SOCKET ERROR"); } else { socket_set_timeout($this->_socket, 10); } }