I'm trying to make an application using XML-RPC, and I have thefollowing problem: I use fsockopen() to simulate a POST to my localweb-server. All goes very well except it's very very slow. Here is mycode maybe someone could tell me what I'm doing wrong:
$url=parse_url($this->serverURL);
$requestString= "POST ".$url['path']." HTTP/1.1\r\nHost:".$url['host']."\r\nContent-type:application/x-www.form-urlencoded\r\nContent-length:".strlen($this->requestData)."\r\n\r\n".$this->requestData;;
$fp = fsockopen($url['host'], 80, $err_num, $err_msg, 5);
if ($fp)
{
//make the request to the xml-rpc server
fputs($fp, $requestString); //gets the result
while (!feof($fp))
{
$response .= fgets($fp, 1024);
}
fclose($fp);
$this->rawResponse=$response;
$this->error=false;
}
else
{
$this->error=true;
$this->errorMessage=$err_msg;
}
====================================
This is the slowest part of my script(about 16 seconds). The server'sexecution time is only 0.00064206123352051 seconds. I don't know why ittakes so much to write a string to the socket and then to read theresponse.
Here are the execution times:
Server Start Server Stop
1067090777.5339 1067090777.5346
Client Start Client Stop
1067090777.5303 1067090794.5286
If someone knows a way on how to speed this up please tell me how to doit.