Dear BrowserUk, thank you for your reply.
Please tell me what to do if the call setsokopt setsockopt($sock, 6, 18, pack("QQ", 5, 0)) or die "setsockopt SOL_TCP, TCP_USER_TIMEOUT: $!\n";
returns an error "protocol not available"?
Assuming you're on some form of *nix, you could investigate whether a newer version based on a later kernel has implemented this (relatively new) option in its tcpip stack.
Barring that, you would have no option but to effectively implement it yourself within your application.
One way to do that would be each time you successfully send a request, push the socket handle for that client into a hash of arrays keyed by the timeout elapse time. And then each time your poll returns or times out, once you have dealt with any events returned by poll, inspect the array for the curent timeslot (if any), close the handles and remove them from your poll list.
In an attempt to clarify: After a successful send, push the socket handle to an array keyed by the current time rounded to neasest second + your desired timeout: