resource fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get("default_socket_timeout") ]]]] )
Open Internet or Unix domain socket connection
Initiates a socket connection to the resource specified by hostname.
<?php
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}?>
4.3.0 Added support for the timeout parameter on win32. 4.3.0 SSL and TLS over TCP/IP support was added.
Question: Give me working Example of fsockopen?
$fp = fsockopen('example.com', 80); $postVars = array( 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3', 'key4' => 'value4' ); $postContent = http_build_query($postVars); fwrite($fp, "POST /reposter.php HTTP/1.1\r\n"); fwrite($fp, "Host: example.com\r\n"); fwrite($fp, "Content-Type: application/x-www-form-urlencoded\r\n"); fwrite($fp, "Content-Length: ".strlen($postContent)."\r\n"); fwrite($fp, "Connection: close\r\n"); fwrite($fp, "\r\n"); fwrite($fp, $postContent); header('Content-type: text/plain'); while (!feof($fp)) { echo fgets($fp, 1024); }
Tutorial para configurar ButterStorm