The streams returned from fsockopen()
are a managed wrapper around regular sockets; the unread bytes (which is what you're probably after) is the difference between the read()
on the socket (made by the wrapper itself) and the fread()
on the wrapper (made by your script).
The wrapper reads in chunks of 8192 bytes, but the fread()
or fgets()
may not read all data at once, which is why there's an unread
meta data field you could query; whether that's useful is another thing ;-)
When using regular sockets, you could either:
- use
socket_select()
to wait for data to become available, followed by a suitably large socket_read()
- use
socket_set_nonblock()
to make the socket unblocked and attempt to read from it