again fsockopen
Posted: Fri Jun 06, 2008 4:46 am
hello,
i have a problem with fsockopen.
i send a xml-file to webserver and wait for the answer.
the script is very slow.
so i debug with timesteps.
i call the script 4 times in a minute and the time between Step 1 and two is different.
at the end (call4) the response is very fast.
15 seconds later again
another 15 seconds later
another 15 seconds later
can anybody tell me, why the first fgets is so slow, and why the fgets is getting faster in the other calls ?
bye jogi
i have a problem with fsockopen.
i send a xml-file to webserver and wait for the answer.
Code: Select all
$fp = fsockopen("ssl://server.com",443,$errstr,$errno);
if(!$fp)
{
die();
}
else
{
$file = addslashes($file);
$data = $file;
fputs($fp, "POST /webservice/XMLServlet HTTP/1.0\r\n");
fputs($fp, "Host: server.com\r\n");
fputs($fp, "Authorization: Basic ".$kennung." \r\n");
fputs($fp, "Content-length: ". strlen($data) ."\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);
}
$xxx = 1;
while(!feof($fp))
{
echo "Step ".$xxx." : ".date("d.m.Y - H:i:s")."<br>\n";
$data .= fgets($fp, 2048);
$xxx++;
}
so i debug with timesteps.
i call the script 4 times in a minute and the time between Step 1 and two is different.
at the end (call4) the response is very fast.
Code: Select all
1 : 06.06.2008 - 11:29:45<br>
2 : 06.06.2008 - 11:30:08<br>
3 : 06.06.2008 - 11:30:08<br>
4 : 06.06.2008 - 11:30:08<br>
5 : 06.06.2008 - 11:30:08<br>
6 : 06.06.2008 - 11:30:08<br>
7 : 06.06.2008 - 11:30:08<br>
8 : 06.06.2008 - 11:30:08<br>
9 : 06.06.2008 - 11:30:08<br>Code: Select all
1 : 06.06.2008 - 11:30:58<br>
2 : 06.06.2008 - 11:31:22<br>
3 : 06.06.2008 - 11:31:22<br>
4 : 06.06.2008 - 11:31:22<br>
5 : 06.06.2008 - 11:31:22<br>
6 : 06.06.2008 - 11:31:22<br>
7 : 06.06.2008 - 11:31:22<br>
8 : 06.06.2008 - 11:31:22<br>
9 : 06.06.2008 - 11:31:22<br>Code: Select all
1 : 06.06.2008 - 11:33:01<br>
2 : 06.06.2008 - 11:33:05<br>
3 : 06.06.2008 - 11:33:05<br>
4 : 06.06.2008 - 11:33:05<br>
5 : 06.06.2008 - 11:33:05<br>
6 : 06.06.2008 - 11:33:05<br>
7 : 06.06.2008 - 11:33:05<br>
8 : 06.06.2008 - 11:33:05<br>
9 : 06.06.2008 - 11:33:05<br>
Code: Select all
1 : 06.06.2008 - 11:33:28<br>
2 : 06.06.2008 - 11:33:31<br>
3 : 06.06.2008 - 11:33:31<br>
4 : 06.06.2008 - 11:33:31<br>
5 : 06.06.2008 - 11:33:31<br>
6 : 06.06.2008 - 11:33:31<br>
7 : 06.06.2008 - 11:33:31<br>
8 : 06.06.2008 - 11:33:31<br>
9 : 06.06.2008 - 11:33:31<br>
10 : 06.06.2008 - 11:33:31<br>
11 : 06.06.2008 - 11:33:31<br>
12 : 06.06.2008 - 11:33:31<br>
13 : 06.06.2008 - 11:33:31<br>
14 : 06.06.2008 - 11:33:31<br>
15 : 06.06.2008 - 11:33:31<br>
16 : 06.06.2008 - 11:33:31<br>
bye jogi