The practical side: I have a load of sockets from which I am reading. They are IO::Socket objects attached to an IO::Select. I want to loop through them using while (@handles =IO::Select->select ($sel, undef, $self, 1) ) and read a line at a time. The idea is, it is faster to do this than to read each one in turn: I am trying to parallelize my socket reading.
So far, so good... but I have a problem. Normally, with just one socket, I can read the socket "to the end" by using <> in array context. With my new solution, I don't want to read the socket to the end - I just want one line at a time. But I do want to find out when data has finished coming over a socket. Otherwise, I end up going round and round the select() call.
That's the practical question: how do I find out when a data has finished coming over a socket, the same way perl does when I use the angle operator in array context, so as to remove the socket from my IO::Select?
The theoretical question is: what's the underlying mechanism? I know an HTML page is finished cos it says </HTML>. But how does one know a socket is finished? Does it communicate this fact at all? Or are you just supposed to guess because it has stopped talking to you?
Awaiting enlightenment.
dave hj~
In reply to Knowing an IO::Socket handle has reached end-of-file by dash2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |