Socket problem
Posted: Sat Jul 17, 2004 1:05 am
feyd | ***LAST WARNING*** use
feyd | ***LAST WARNING*** use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi,
I am using following code to connect to socket.
The socket get connected properly but in response server redirect me to blank page.
In response I get <script>javascript.back()</script>
Please let me know the problem.Why the server is redirecting me to blank page?Code: Select all
<?
$filename = "request.xml";//has some xml data
$fp = fopen($filename,"r");
$requestxml = fread($fp,filesize($filename));
fclose($fp);
$time_out_val=30;
// Initialize the response variable
$response = "";
$header = "POST /cgi-bin/d3web.sky HTTP/1.0\r\n";
$header .= "Content-type: application/x-www-form-urlencoded\r\n";
$header .= "Content-length: " . strlen($requestxml) ."\r\n\r\n";
$connection = fsockopen("www.myhost.com", 80, &$error_number, &$error_description, 50);
if($connection)
{
// Send the request block
fputs($connection, $header);
fputs($connection, $requestxml);
while ( ! feof( $connection ) )
$response .= fgets( $connection, 1024 );
fclose( $connection );
// Return the data block
$fp = fopen("test.xml","w+");
fwrite($fp, $response);
fclose($fp);
echo $response;
//return true;
die("connected tosite");
}
else
{
// socket connection failed
die("Failed to connect ");
}
?>Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]