0day has asked for the
wisdom of the Perl Monks concerning the following question:

Hi Monks.Tell me please how i can set the timeout for an established connection, which I can not get the data for a long time?Example http://stockzooi.com/
I handle a lot of sockets with a "poll" in loop:

But these connections cannot be processed in this cycle.
I did this:setsockopt($sock, SOL_SOCKET, SO_RCVTIMEO, pack("QQ", 10, 0)) and waited for the error on the socket.
But this does not occur and the connection remains frozen.

Set or get the timeout value (in seconds) associated with this socket. If called without any arguments then the current setting is returned. If called with an argument the current setting is changed and the previous value returned.

SO_RCVTIMEO parameter sets timeout for recv call. As you're using poll you have to handle timeouts yourself. After each poll check if there are sockets which didn't have data to read for more than 10 seconds and close them.

How to do it? Check each socket?
Suppose, there is 1000 sockets. Poll said that two of them are available to read. During 0.2 seconds, will be available for 2 more. You say every time check the other 998?

Ok. There is a spider that walks the http links. Spider has a limited number of connections, let it be 10.If we run this spider and he will eat 10 such references (http://stockzooi.com/), then it stops working.
Because IO::Poll, as well as IO::Selekt not notified about the data recv.

Connection occurs. The data is sent. No response from the server.

On my computer, the browser tries to open this site 24 hours.
If the connections is the only one we can close it when the IO::Poll returns zero (timeout).But this did not happen, because the remaining 9 connections will be processed normally.
Soon the spider will eat one same link. Working connections will remain 8.Etc.

I thought I did. :-) IO::Select can be used to set a timeout on reading a socket filehandle. Why aren't you using it? I thought it was in one of the links I listed above.

FWIW, the method which I found to be workable, comes from the way event-loop systems, like Glib or AnyEvent does it. In those systems, when you you get the meta data from the socket connection that an 'IN' condition has occured, but yet there is no data there to be read, then your connection is caput. See Gtk2 server and client GUI's with root messaging for an example.