Re[2]: socket_write buffer problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux