当前位置: 首页>>代码示例>>PHP>>正文


PHP socket_set_timeout函数代码示例

本文整理汇总了PHP中socket_set_timeout函数的典型用法代码示例。如果您正苦于以下问题:PHP socket_set_timeout函数的具体用法?PHP socket_set_timeout怎么用?PHP socket_set_timeout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了socket_set_timeout函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkPassword

 /**
  * 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;
 }
开发者ID:teammember8,项目名称:roundcube,代码行数:34,代码来源:imap.php

示例2: getResponse

 /**
  * 获取请求的响应
  * @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;
 }
开发者ID:shapemyself,项目名称:testRepo,代码行数:65,代码来源:testgetcontent.php

示例3: connect

 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;
     }
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:27,代码来源:ezclustersmtp.php

示例4: Connect

 /**
  * @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);
         }
     }
 }
开发者ID:diedsmiling,项目名称:busenika,代码行数:36,代码来源:class_smtp.php

示例5: connect

 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: " . $username . "\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;
 }
开发者ID:carriercomm,项目名称:Freeside,代码行数:34,代码来源:asi.php

示例6: SetOptions

 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);
 }
开发者ID:njorth,项目名称:tsock,代码行数:7,代码来源:SocketConnection.php

示例7: _Set_Timeout

 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);
 }
开发者ID:andregirol,项目名称:uxpanel,代码行数:7,代码来源:rcon.php

示例8: pyphp_init

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;
}
开发者ID:sl-depo,项目名称:qweb,代码行数:29,代码来源:pyphp.php

示例9: _sendXmlRequest

 /**
  * 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;
 }
开发者ID:abhinay100,项目名称:forma_app,代码行数:40,代码来源:ConferenceTeleSkillPlugin.php

示例10: connect

 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;
         }
     }
 }
开发者ID:dlpc,项目名称:ecshop,代码行数:29,代码来源:cls_smtp.php

示例11: queryServer

 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=" . $this->password)) {
                 return 0;
             }
         }
         $response = "";
         $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;
 }
开发者ID:prototux,项目名称:old,代码行数:27,代码来源:ts3.class.php

示例12: Connect

 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;
 }
开发者ID:BACKUPLIB,项目名称:minimanager,代码行数:32,代码来源:class.smtp.php

示例13: getRemoteContents

 /**
  * 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;
     }
 }
开发者ID:noblexity,项目名称:RankFace,代码行数:32,代码来源:RankService.php

示例14: GetStatus

 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=" . $pw . "&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;
     }
 }
开发者ID:MichaelFichtner,项目名称:RadioLaFamilia,代码行数:34,代码来源:gr_radiostatus_class.php

示例15: Connect

 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;
 }
开发者ID:hackingman,项目名称:TubeX,代码行数:30,代码来源:SMTP.php


注:本文中的socket_set_timeout函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。