Jump to content

XML-RPC request confusion


kostakondras

Recommended Posts

I am very confused at an example in a book I am reading called Beggining PHP regarding XML-RPC requests. I will write the code below:

 

function send($remoteServer, $remotePort, $fullXMLRPCRequest) {
     $headers = '';
     $data = '';
     $socket = fsockopen($remoteServer, $remotePort);
     fwrite($socket, $fullXMLRPCRequest);
     while ($str = trim(fgets($socket))) { // why doesn't this exhaust the returned call??
          $headers .= $str . "\n";
     }
     while (!feof($socket)) {
          $data .= fgets($socket);
     }
     fclose($socket);
     return $data;
}

 

The question I have is notice how there are two while statements and they both access the same resource ($socket). So how can there be two while statements?? Wouldn't the first while statement exhaust the resource and there would be nothing on the second while statement? I hope this makes sense. It's sort of like saying while(x < 10) { //execute... ++x; } then another while statement while(x < 10) { //execute... ++x; }

 

Well then wouldn't the second while statement not execute? I hope I made sense.

 

Thanks for all the help in advance. Obviously knowing XML-RPC would help in answering this question, hopefully most of you are familiar with it.

 

Link to comment
https://forums.phpfreaks.com/topic/225601-xml-rpc-request-confusion/
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.