Go Back   Forum Care Forums > Development Reference Area > Php Development

Reply
 
LinkBack Thread Tools Display Modes
Re[2]: [PHP] socket_write buffer problem
Old
  (#1)
Richard Luckhurst
Guest
 
Posts: n/a
Default Re[2]: [PHP] socket_write buffer problem - 05-14-2007, 03:36 AM

Hi Jochem,


JM> I would start by reading the relevant page:

JM> http://php.net/socket_write

JM> after reading that your first attempt will probably be this
JM> (you may have complication is your using a multibyte charset):

As I had said in my earlier post I had already read the php manual section for
socket_write.

JM> socket_write($client, $yresponse, strlen($yresponse));

JM> if that doesn't work, you will be looking at capturing the return value
JM> of socket_write() in order to determine how many bytes were sent ...
JM> this information will allow to to use a loop to call socket_write as many times
JM> as is required to send all the data. hope that makes sense to you.

I tried the strlen($yresponse) length option in socket_write and it did not
matter if I set socket_write to anything larger than 1024. It appears that there
is a buffer with a size of 1024 and in my case the length option would only be
of use if the string I wanted to send was shorter than the size of the buffer.

Rather than capturing the return value of socket_write I broke my test string
into 2 chunks as the total was less than 2048 bytes.

What I tried was

// grab first 1024 bytes
$buffer = substr($yresponse,0,1024);
// send first 1024 bytes
socket_write($client, $buffer);
// replace first 1024 bytes with ''
$buffer = substr_replace($yresponse,'',0,1024);
//send the remainder of the string
socket_write ($client, $buffer);

What I found was that the first 1024 bytes was sent but I still never saw the
second 1024 bytes. It seem the second socket_write is not happening.

Am I on the right track here?

>>
>>
>>
>>
>> Regards,
>> Richard Luckhurst
>> Product Development
>> Exodus Systems - Sydney, Australia.
>>

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top