• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP stream_set_timeout函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: load_data

/**
 * Send request to VIES site and retrieve results
 *
 * @access  public
 * @param   string
 * @return  mixed
 */
function load_data($url)
{
    $url = parse_url($url);
    if (!in_array($url['scheme'], array('', 'http'))) {
        return false;
    }
    $fp = fsockopen($url['host'], $url['port'] > 0 ? $url['port'] : 80, $errno, $errstr, 2);
    if (!$fp) {
        return false;
    } else {
        fputs($fp, "GET " . $url['path'] . (isset($url['query']) ? '?' . $url['query'] : '') . " HTTP/1.0\r\n");
        fputs($fp, "Host: " . $url['host'] . "\r\n");
        fputs($fp, "Connection: close\r\n\r\n");
        $data = '';
        stream_set_blocking($fp, false);
        stream_set_timeout($fp, 4);
        $status = socket_get_status($fp);
        while (!feof($fp) && !$status['timed_out']) {
            $data .= fgets($fp, 1000);
            $status = socket_get_status($fp);
        }
        if ($status['timed_out']) {
            return false;
        }
        fclose($fp);
        return $data;
    }
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:35,代码来源:function_validate_vatid.php


示例2: _recv

 protected function _recv()
 {
     stream_set_timeout($this->_fp, 0, $this->_timeout_recv);
     $data = fread($this->_fp, 24);
     $info = stream_get_meta_data($this->_fp);
     if ($info['timed_out']) {
         return FALSE;
     }
     $array = $this->_show_request($data);
     if ($array['bodylength']) {
         $bodylength = $array['bodylength'];
         $data = '';
         while ($bodylength > 0) {
             $recv_data = fread($this->_fp, $bodylength);
             $bodylength -= strlen($recv_data);
             $data .= $recv_data;
         }
         if ($array['extralength']) {
             $extra_unpacked = unpack('Nint', substr($data, 0, $array['extralength']));
             $array['extra'] = $extra_unpacked['int'];
         }
         $array['key'] = substr($data, $array['extralength'], $array['keylength']);
         $array['body'] = substr($data, $array['extralength'] + $array['keylength']);
     }
     return $array;
 }
开发者ID:aatty,项目名称:Heroku-Memcachier,代码行数:26,代码来源:Memcachesasl.php


示例3: connect

 public function connect($ip, $port)
 {
     $this->remoteip = $ip;
     $this->remoteport = $port;
     $errno = 0;
     $errstr = '';
     logger::debug("Connecting to %s:%d", $ip, $port);
     $this->state = SOCKSTATE_CONNECTING;
     $this->fsh = fsockopen($ip, $port, $errno, $errstr);
     if ($errno) {
         logger::warning("Socket error: %d %s (%s:%d)", $errno, $errstr, $ip, $port);
         $this->state = SOCKSTATE_ERROR;
         return false;
     } else {
         if (!$this->fsh) {
             $this->state = SOCKSTATE_ERROR;
             logger::warning("No socket handle returned but no error indicated");
             return false;
         }
         logger::debug("Socket connected to %s:%d", $ip, $port);
         stream_set_timeout($this->fsh, 0, 200);
         $this->state = SOCKSTATE_CONNECTED;
         return true;
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:25,代码来源:sockets.php


示例4: connect

 function connect()
 {
     $this->online_start = microtime(true);
     $this->main->log('Connecting to ' . $this->info['address'] . '...', __CLASS__);
     $this->socket = @fsockopen($this->info['address'], $this->info['port'], $erno, $errstr, 30);
     @stream_set_blocking($this->socket, false);
     @stream_set_timeout($this->socket, $this->listen_timeout);
     if ($this->state() == false) {
         $this->main->log('Could not connect to ' . $this->info['address'] . ': (' . $erno . ') ' . $errstr, __CLASS__);
         $this->reconnect();
     } else {
         $this->retry_count = 0;
         $this->main->log('Connection to IRC-server established', __CLASS__);
         //Connection stuff
         if (!empty($this->info['pass'])) {
             $this->main->log('Sending stored password', __CLASS__);
             $this->main->send_data('PASS ' . $this->info['pass'], IRCINE_PRIO_CRITICAL);
         }
         $this->main->log('Authenticating to IRC-server', __CLASS__);
         $this->nickname(Mootyconf::get_value('deerkins::nick'));
         $this->main->log('Sending ident info', __CLASS__);
         $this->main->send_data('USER ' . $this->info['ident'] . ' ' . $this->info['address'] . ' * :' . $this->info['realname'], IRCINE_PRIO_CRITICAL);
         // Idents with server
         $this->main->log('Connection to ' . $this->info['address'] . ' succeeded!', __CLASS__);
         $this->listen();
     }
 }
开发者ID:unnes,项目名称:deerkins,代码行数:27,代码来源:ircine.connection.php


示例5: dial

 /**
  * Initialize connection to JSON-RPC server.
  *
  * @throws Exception\JsonRPCException
  */
 function dial()
 {
     $conn = @fsockopen($this->host, $this->port, $errorNumber, $errorString, 5);
     if (!$conn) {
         throw new JsonRPCException(sprintf('An error appeared while connecting to RPC server: %s (%d)', $errorNumber, $errorString), $errorNumber);
     }
     $request = 'CONNECT ' . $this->path . ' HTTP/1.0' . "\n";
     if (array_key_exists('dial_headers', $this->options)) {
         foreach ($this->options['dial_headers'] as $header => $value) {
             $request .= $header . ': ' . $value . "\n";
         }
     }
     @fwrite($conn, $request . "\n");
     stream_set_timeout($conn, 0, 3000);
     do {
         $line = @fgets($conn);
     } while ($line !== false && empty($line));
     $success = 'HTTP/1.0 200 Connected';
     if ($line === false) {
         throw new JsonRPCException('An error appeared while reading from RPC server');
     } else {
         if (substr($line, 0, strlen($success)) != $success) {
             @fclose($conn);
             throw new JsonRPCException(sprintf('Unexpected HTTP response while connecting: %s', $line));
         }
     }
     $this->connection = $conn;
 }
开发者ID:sroze,项目名称:discoverd-client,代码行数:33,代码来源:JsonRPCClient.php


示例6: InitUrlSocket

 private function InitUrlSocket()
 {
     $i = $CreateCount = $ErrCount = 0;
     $errno = $errstr = 0;
     foreach ($this->Sockets as $Key => $UrlUnit) {
         $Urls = $UrlUnit['Urls'];
         $Port = empty($Urls['port']) ? '80' : $Urls['port'];
         $s = stream_socket_client($Urls['host'] . ':' . $Port, $errno, $errstr, $this->ConnectTimeout, STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT);
         if ($s) {
             stream_set_timeout($s, 0, $this->StreamTimeout);
             $this->Sockets[$Key]['Socket'] = $s;
             $this->Sockets[$Key]['Data'] = '';
             $this->Sockets[$Key]['Succ'] = false;
             $this->Sockets[$Key]['HttpStates'] = array();
             $this->Sockets[$Key]['State'] = 0;
             $this->Sockets[$Key]['Location'] = '';
             $this->Sockets[$Key]['DataLen'] = 0;
             $CreateCount++;
         } elseif ($ErrCount == 3) {
             exit('cannot connection internet');
         } else {
             unset($this->Sockets[$Key]);
             $ErrCount++;
         }
     }
     return $CreateCount;
 }
开发者ID:huangwei2wei,项目名称:kfxt,代码行数:27,代码来源:HJMultiSocket.class.php


示例7: http_send

function http_send($_url, $_body)
{
    $errno = 0;
    $errstr = '';
    $timeout = 10;
    $fp = fsockopen(_IP_, _PORT_, $errno, $errstr, $timeout);
    if (!$fp) {
        return FALSE;
    }
    $_head = "POST /" . $_url . " HTTP/1.1\r\n";
    $_head .= "Host: " . _IP_ . ":" . _PORT_ . "\r\n";
    $_head .= "Content-Type: Text/plain\r\n";
    if (!$_body) {
        $body_len = 0;
    } else {
        $body_len = strlen($_body);
    }
    $send_pkg = $_head . "Content-Length:" . $body_len . "\r\n\r\n" . $_body;
    ilog(iLOG_INFO, "    -----> http_send url: " . $_url);
    ilog(iLOG_INFO, "    -----> http_send body: " . $_body);
    if (fputs($fp, $send_pkg) === FALSE) {
        return FALSE;
    }
    //设置3s超时
    stream_set_timeout($fp, 3);
    while (!feof($fp)) {
        ilog(iLOG_INFO, "    -----> rsp: " . fgets($fp, 128));
    }
    if ($fp) {
        fclose($fp);
    }
    return TRUE;
}
开发者ID:yonglinchen,项目名称:shopping,代码行数:33,代码来源:ihttp.php


示例8: setSocketTimeout

 public function setSocketTimeout($seconds)
 {
     $this->config['socket_timeout'] = $seconds;
     if (isset($this->connection) && $seconds > 0) {
         stream_set_timeout($this->connection, $seconds);
     }
 }
开发者ID:TheProjecter,项目名称:skeleton,代码行数:7,代码来源:Smtp.php


示例9: connect

 /**
  * Connects and authenticates to SMTP server.
  * @return void
  */
 private function connect()
 {
     $this->connection = @fsockopen(($this->secure === 'ssl' ? 'ssl://' : '') . $this->host, $this->port, $errno, $error, $this->timeout);
     if (!$this->connection) {
         throw new SmtpException($error, $errno);
     }
     stream_set_timeout($this->connection, $this->timeout, 0);
     $this->read();
     // greeting
     $self = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost';
     $this->write("EHLO {$self}");
     if ((int) $this->read() !== 250) {
         $this->write("HELO {$self}", 250);
     }
     if ($this->secure === 'tls') {
         $this->write('STARTTLS', 220);
         if (!stream_socket_enable_crypto($this->connection, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
             throw new SmtpException('Unable to connect via TLS.');
         }
         $this->write("EHLO {$self}", 250);
     }
     if ($this->username != NULL && $this->password != NULL) {
         $this->write('AUTH LOGIN', 334);
         $this->write(base64_encode($this->username), 334, 'username');
         $this->write(base64_encode($this->password), 235, 'password');
     }
 }
开发者ID:anagio,项目名称:woocommerce,代码行数:31,代码来源:SmtpMailer.php


示例10: __construct

 /**
  * @param string $host
  * @param int $port
  * @param int $connectTimeout
  */
 public function __construct($host, $port, $connectTimeout)
 {
     if (!($this->_socket = @fsockopen($host, $port, $errno, $errstr, $connectTimeout))) {
         throw new Pheanstalk_Exception_ConnectionException($errno, $errstr);
     }
     stream_set_timeout($this->_socket, self::SOCKET_TIMEOUT);
 }
开发者ID:nauzet18,项目名称:consig,代码行数:12,代码来源:NativeSocket.php


示例11: open

 public function open($host, $port, $transport = 'tcp')
 {
     // if a socket is current open then close it
     $this->close();
     if (($ip = filter_var($host, FILTER_VALIDATE_IP)) !== false) {
         $this->host = $ip;
     } elseif (($ip = gethostbyname($host)) != $host) {
         $this->host = $ip;
     } else {
         throw new Exception('Unable to resolve host: ' . $host);
     }
     $this->port = filter_var($port, FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'max_range' => 65535)));
     if (!$this->port) {
         throw new Exception('Invalid Port: ' . $port);
     }
     $err = 0;
     $msg = '';
     $this->stream = fsockopen("{$transport}://{$this->host}", $this->port, $err, $msg, $this->timeout);
     if (!$this->isOpen()) {
         throw new Exception("Unable to open socket: {$msg}", $err);
     }
     stream_set_timeout($this->stream, $this->timeout);
     stream_set_blocking($this->stream, $this->block);
     return $this;
 }
开发者ID:simon-downes,项目名称:spf,代码行数:25,代码来源:Socket.php


示例12: __construct

 function __construct($config)
 {
     if (extension_loaded("pcntl")) {
         //Add signal handlers to shut down the bot correctly if its getting killed
         pcntl_signal(SIGTERM, array($this, "signalHandler"));
         pcntl_signal(SIGINT, array($this, "signalHandler"));
     } else {
         //die("Please make sure the pcntl PHP extension is enabled.\n");
     }
     $this->config = $config;
     $this->startTime = time();
     $this->lastServerMessage = $this->startTime;
     ini_set("memory_limit", $this->config['memoryLimit'] . "M");
     if ($config['verifySSL']) {
         $this->socket = stream_socket_client("" . $config['server'] . ":" . $config['port']) or die("Connection error!");
     } else {
         $socketContext = stream_context_create(array("ssl" => array("verify_peer" => false, "verify_peer_name" => false)));
         $this->socket = stream_socket_client("" . $config['server'] . ":" . $config['port'], $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $socketContext) or die("Connection error!");
     }
     stream_set_blocking($this->socket, 0);
     stream_set_timeout($this->socket, 600);
     $this->login();
     $this->loadPlugins();
     $this->main($config);
 }
开发者ID:sergejey,项目名称:majordomo-app_ircbot,代码行数:25,代码来源:VikingBot.php


示例13: scrape

 public function scrape($url, $infohash)
 {
     if (!is_array($infohash)) {
         $infohash = array($infohash);
     }
     foreach ($infohash as $hash) {
         if (!preg_match('#^[a-f0-9]{40}$#i', $hash)) {
             throw new ScraperException('Invalid infohash: ' . $hash . '.');
         }
     }
     $url = trim($url);
     if (preg_match('%(http://.*?/)announce([^/]*)$%i', $url, $m)) {
         $url = $m[1] . 'scrape' . $m[2];
     } else {
         if (preg_match('%(http://.*?/)scrape([^/]*)$%i', $url, $m)) {
         } else {
             throw new ScraperException('Invalid tracker url.');
         }
     }
     $sep = preg_match('/\\?.{1,}?/i', $url) ? '&' : '?';
     $requesturl = $url;
     foreach ($infohash as $hash) {
         $requesturl .= $sep . 'info_hash=' . rawurlencode(pack('H*', $hash));
         $sep = '&';
     }
     ini_set('default_socket_timeout', $this->timeout);
     $rh = @fopen($requesturl, 'r');
     // var_dump($url);
     if (!$rh) {
         throw new ScraperException('Could not open HTTP connection.', 0, true);
     }
     stream_set_timeout($rh, $this->timeout);
     $return = '';
     $pos = 0;
     while (!feof($rh) && $pos < $this->maxreadsize) {
         $return .= fread($rh, 1024);
     }
     fclose($rh);
     if (!substr($return, 0, 1) == 'd') {
         throw new ScraperException('Invalid scrape response.');
     }
     $lightbenc = new lightbenc();
     $arr_scrape_data = $lightbenc->bdecode($return);
     $torrents = array();
     foreach ($infohash as $hash) {
         $ehash = pack('H*', $hash);
         if (isset($arr_scrape_data['files'][$ehash])) {
             if (array_key_exists('downloaded', $arr_scrape_data['files'][$ehash])) {
                 $completed = $arr_scrape_data['files'][$ehash]['downloaded'];
             } else {
                 $completed = "0";
             }
             $torrents[$hash] = array('infohash' => $hash, 'seeders' => (int) $arr_scrape_data['files'][$ehash]['complete'], 'completed' => (int) $completed, 'leechers' => (int) $arr_scrape_data['files'][$ehash]['incomplete']);
         } else {
             $torrents[$hash] = false;
         }
     }
     // var_dump($torrents);
     return $torrents;
 }
开发者ID:doio,项目名称:Bittytorrent,代码行数:60,代码来源:httptscraper.php


示例14: connect

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


示例15: send

 /**
  * Send data through the socket and listen for a return
  * @param string $msg Data to send
  * @param string $type The type of data to return (array or string)
  * @return string|array
  */
 function send($msg, $type = '')
 {
     // Set a short timeout to prevent long hangs
     stream_set_timeout($this->handle, 2);
     // Send message over connection
     fwrite($this->handle, $msg);
     // Check what type is required
     if ($type == 'array') {
         // If array loop and create array
         $response = array();
         $line_num = 0;
         while (!feof($this->handle)) {
             if (($response[$line_num] = fgets($this->handle, 4096)) === false) {
                 break;
             } else {
                 $line_num++;
             }
         }
         // Return response as array
         return $response;
     } elseif ($type == 'string') {
         // If string, loop and create string
         $response = '';
         while (!feof($this->handle)) {
             $response .= fgets($this->handle, 4096);
         }
         // Return response as string
         return $response;
     } else {
         // If anything else, return nothing but a true
         return true;
     }
 }
开发者ID:jensz12,项目名称:PHP-Last.fm-API,代码行数:39,代码来源:Socket.php


示例16: 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


示例17: SendMsg2Daemon

function SendMsg2Daemon($ip, $port, $msg, $timeout = 15)
{
    if (!$ip || !$port || !$msg) {
        return array(false);
    }
    $errno;
    $errstr;
    $fp = @fsockopen($ip, $port, $errno, $errstr, $timeout);
    if (!$fp) {
        return array(false);
    }
    stream_set_blocking($fp, true);
    stream_set_timeout($fp, $timeout);
    @fwrite($fp, $msg . "\n");
    $status = stream_get_meta_data($fp);
    $ret;
    if (!$status['timed_out']) {
        $datas = 'data:';
        while (!feof($fp)) {
            $data = fread($fp, 4096);
            if ($data) {
                $datas = $datas . $data;
            }
        }
        return array(true, $datas);
    } else {
        $ret = array(false);
    }
    @fclose($fp);
    return ret;
}
开发者ID:ifzz,项目名称:distri.lua,代码行数:31,代码来源:control_action.php


示例18: stardust_do_post_request

function stardust_do_post_request($found) {
    $params = array('http' => array(
            'method' => 'POST',
            'content' => implode(',', $found)
            ));
    if ($optional_headers !== null) {
        $params['http']['header'] = $optional_headers;
    }
    $ctx = stream_context_create($params);
    $timeout = 15;
    $old = ini_set('default_socket_timeout', $timeout);
    $fp = @fopen(STARDUST_SERVICE_URL, 'rb', false, $ctx);
    ini_set('default_socket_timeout', $old);
    if ($fp) {
        stream_set_timeout($fp, $timeout);
        stream_set_blocking($fp, 3);
    } else
        //throw new Exception("Problem with " . STARDUST_SERVICE_URL . ", $php_errormsg");
        return false;
    $response = @stream_get_contents($fp);
    if ($response === false) {
        //throw new Exception("Problem reading data from " . STARDUST_SERVICE_URL . ", $php_errormsg");
    }
    return $response;
}
开发者ID:VirtualReality,项目名称:WebUI,代码行数:25,代码来源:stardust.php


示例19: send

 /**
  * @param null $host - $host of socket server
  * @param null $port - port of socket server
  * @param string $action - action to execute in sockt server
  * @param null $data - message to socket server
  * @param string $address - addres of socket.io on socket server
  * @param string $transport - transport type
  * @return bool
  */
 public function send($host = null, $port = null, $action = "message", $data = null, $address = "/socket.io/?EIO=3", $transport = 'websocket')
 {
     $fd = fsockopen($host, $port, $errno, $errstr);
     if (!$fd) {
         return false;
     }
     //Can't connect tot server
     $key = $this->generateKey();
     $out = "GET {$address}&sessionid=&transport={$transport} HTTP/1.1\r\n";
     $out .= "Host: http://{$host}:{$port}\r\n";
     $out .= "Upgrade: WebSocket\r\n";
     $out .= "Connection: Upgrade\r\n";
     $out .= "Sec-WebSocket-Key: {$key}\r\n";
     $out .= "Sec-WebSocket-Version: 13\r\n";
     $out .= "Origin: *\r\n\r\n";
     stream_set_timeout($fd, 5);
     fwrite($fd, $out);
     // 101 switching protocols, see if echoes key
     $result = fread($fd, 10000);
     preg_match('#Sec-WebSocket-Accept:\\s(.*)$#mU', $result, $matches);
     $keyAccept = trim($matches[1]);
     $expectedResonse = base64_encode(pack('H*', sha1($key . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11')));
     $handshaked = $keyAccept === $expectedResonse ? true : false;
     if ($handshaked) {
         fwrite($fd, $this->hybi10Encode('42["' . $action . '", "' . addslashes($data) . '"]'));
         fread($fd, 1000000);
         sleep(2);
         fclose($fd);
         return true;
     } else {
         return false;
     }
 }
开发者ID:husnusetiawan,项目名称:PHP_SocketIO_Client,代码行数:42,代码来源:SocketIO.php


示例20: call_async_fsockopen

function call_async_fsockopen($script_path, $data = null)
{
    if (empty($data)) {
        $out = "GET {$script_path} HTTP/1.1\r\n";
        $out .= "Host: {$_SERVER['SERVER_NAME']}\r\n";
        $out .= 'User-Agent: ' . ME_USERAGENT . "\r\n";
        $out .= "Connection: Close\r\n";
    } else {
        $post = '';
        while (list($k, $v) = each($data)) {
            $post .= rawurlencode($k) . "=" . rawurlencode($v) . "&";
        }
        $len = strlen($post);
        $out = "POST {$script_path} HTTP/1.1\r\n";
        $out .= "Host: {$_SERVER['SERVER_NAME']}\r\n";
        $out .= 'User-Agent: ' . ME_USERAGENT . "\r\n";
        $out .= "Content-type: application/x-www-form-urlencoded\r\n";
        $out .= "Connection: Close\r\n";
        $out .= "Content-Length: {$len}\r\n";
        $out .= "\r\n";
        $out .= $post . "\r\n";
    }
    $fp = @fsockopen('127.0.0.1', $_SERVER['SERVER_PORT'], $errno, $errstr, 3);
    if ($fp) {
        fwrite($fp, $out);
        stream_set_timeout($fp, 3);
        if ("HTTP/1.1 200 OK\r\n" === fgets($fp)) {
            fclose($fp);
            return 'ok';
        }
    }
    fclose($fp);
    return 'no';
}
开发者ID:sdgdsffdsfff,项目名称:web-pusher,代码行数:34,代码来源:async_call.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP stream_set_write_buffer函数代码示例发布时间:2022-05-23
下一篇:
PHP stream_set_read_buffer函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap