Jump to content

problem reading fsockopen stream


jogisarge

Recommended Posts

hello,

 

i have a problem with fsockopen.

i send a xml-file to webserver and wait for the answer.

 

$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++;
}

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.

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>

 

15 seconds later again

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>

 

another 15 seconds later

 
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>

 

another 15 seconds later

 
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>

 

can anybody tell me, why the first fgets is so slow, and why the fgets is getting faster in the other calls ?

 

bye jogi

Link to comment
https://forums.phpfreaks.com/topic/108959-problem-reading-fsockopen-stream/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.