Well I'm not totally sure, why socket_get_status would
not give you the correct value, other than a bug, as
the manual does indicate the socket functions are

There are altenative ways to get the number of bytes
in the buffer, like using ioctl with FIONREAD,
ofcourse that is a C function, and I can't really
locate a PHP counterpart for it, other than what may
be a counterpart (socket_get_status). However yet
another solution is using the recv() counterpart,
socket_recv() with the MSG_PEEK flag.

Now you'd probably open up a local copy of the php
manpages, hunting for socket_recv()! Well it's not
there, it's an undocumented function (yet), and to my
knowlegde exists in PHP 4.0.7, atleast in the CVS.

function prototype:
mixed socket_recv(resource socket, int len, int flags)

and example usage:
$data = socket_recv($sockfd, $nbytes, MSG_PEEK);
$len = sizeof($data);

Now you would have to loop through the the complete
buffer, and let me remind you, that MSG_PEEK means
peeking into the buffer, it does not "actually" remove
the data from the recv() queue but only gives you a
copy, if you call the function without MSG_PEEK you
will get the same data, and then the data will be

This is one way of finding out the no. of bytes in the
buffer, ofcourse socket_get_status() is surely much

Incase I interpreted you incorrectly and you wanted to
know the no. of bytes the recieve buffer can hold then
here's the function, and this is also 4.0.7+ :

function prototype:
mixed socket_getopt(resource socket, int level, int

example usage:

$info = socket_getopt($sockfd, SOL_SOCKET, SO_RCVBUF);

and it remains pretty much the same for the send
buffer :

$info = socket_getopt($sockfd, SOL_SOCKET, SO_SNDBUF);

Hope that helps.

P.S - phpguru.org, nice domain name.

Know more about me:

Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to