pfsockopen() example:
<?php
$fp = pfsockopen("www.91xjr.com", 80, $errno, $errstr, 20);
if (!$fp) {
echo "$errstr ($errno)<br>";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.91xjr.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
The pfsockopen() function opens a persistent Internet or Unix domain socket connection.
Note: This function is almost identical to fsockopen(). The difference is that the connection is not closed after the script finishes. This function is the persistent version of fsockopen().
pfsockopen(
hostname,
port, errno, errstr, timeout)
Parameter | Description |
---|---|
hostname | Required. Specifies a hostname (like "www.91xjr.com"). ssl:// or tls:// works over TCP/IP to connect to the remote host |
port | Optional. Specifies the port number. Use -1 for transports that do not use ports, like unix:// |
errno | Optional. Specifies the system level error number |
errstr | Optional. Specifies the error message as a string |
timeout | Optional. Specifies the connection timeout (in seconds) |
Return Value: | A file pointer that can be used with other file functions (such as fgets(), fwrite(), fclose()). FALSE on failure. |
---|---|
PHP Version: | 4.0+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!