function to submit data via socket
/** * sendDataOnSocket * function to submit data via socket * @param string $sContent content to send * @param string $sHost Host name * @param string $sFilePath file to post data * @param string $sMethod method name * @return string aig response * @access public */ public static function sendDataOnSocket($sContent,$sHost,$sFilePath,$sMethod) { if(strlen($sHost)==0) { return array(1, "Empty Host name"); }else if (strlen($sMethod)==0) { return array(1, "Empty Method"); } $fp = fsockopen($sHost, "80", $errno, $errstr, 30); if (!$fp) { //could not open socket return array(1, "could not open socket"); } else { $out = $sMethod." ".$sFilePath." HTTP/1.1\r\n"; $out .= "Content-type: application/x-www-form-urlencoded\r\n"; $out .= "Content-Length: ".strlen($sContent)."\r\n"; $out .= "Host: $sHost:80\r\n"; $out .= $sContent; $out .= "\r\n"; fwrite($fp, $out); while (!feof($fp)) { $tempdata = fgets($fp, 128); $data .= $tempdata; } return array(0, $data); } }
Categories: PHP
thanks . i was searching for this code
Nice site.
Nice site.
Nice site.
Nice site.
$fp = fsockopen(”patterns.satishgaudo.com”, “80″, $errno, $errstr, 30);
if (!$fp) {
return false;
} else {
/* Case 1 Create collection */
$content = “action=mailnotification&rname=a&r_prc_id=4888115″;
$out = “POST /patterns.php HTTP/1.1\r\n”;
$out .= “Content-type: application/x-www-form-urlencoded\r\n”;
$out .= “Content-Length: “.strlen($content).”\r\n”;
$out .= “Host: patterns.satishgaudo.com:80\r\n”;
$out .= “Cookie: Rl=satish; rlo=satishgaudo; \r\n\r\n”;
$out .= $content;
$out .= “\r\n”;
fwrite($fp, $out);
while (!feof($fp))
{
$tempdata = fgets($fp, 128);
$data .= $tempdata;
}
echo $data;
}