This is from a socket programming point of view, and has nothing todo with
php in particular (use the logic and map it to php)

your script freeze because it is opened by default in blocking mode:i.e.:
once you reach an end of data situation and you hit a read, the process
with obay you and wait untill something is available on that socket.


two situations you can remedy this:
1- convert the socket to non-blocking (this the call will return with an
error message of "no avaible data"

2- put your touches into the communication, and set in advance the amount
of data expected in ("a predefinded block/structure size"), so you'll be
building your own protocol into the communication say, ok I will send you
x amount of bytes, so read as much as x.


hope this help.
> Hi all,
> I have this stupid issue, I have opened a socket using
> fsockopen<http://www.php.net/manual/en/function.fsockopen.php>,
> I'm reading and writing to this socket, but at some point, I'll be waiting
> for data from that socket, and depending on data input I would write
> something to the socket, also I actually don't know how many lines the
> data
> would be, I can put a little sleep  to be sure that all I need is send,
> but
> how can I read all the data that is currently in the buffer,
> I tried to use
> while (!feof
> <http://www.php.net/manual/en/function.feof.php>($sockethandler))
> {
>    $this->out = fgets <http://www.php.net/manual/en/function.fgets.php>($
> sockethandler);
> }
>
> but I the script just freezes as it does not get any EOF, or EOT signal, I
> only can use this when I send a quit command to the socket so i read all
> the
> rest of the data sent,
> What i need is to read all whats in the buffer right now ....?
>
> Any ideas ....
> --
>                                  Ala'a A. Ibrahim
> http://360.yahoo.com/bai_83
> http://alaa83.blogspot.com/
> _______________________________________________
> General mailing list
> [email protected]
> http://mail.jolug.org/mailman/listinfo/general_jolug.org
>


_______________________________________________
General mailing list
[email protected]
http://mail.jolug.org/mailman/listinfo/general_jolug.org

Reply via email to