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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.