linxdev has asked for the wisdom of the Perl Monks concerning the following question:
This script is just a stand-in script because these devices can't contact the remote directly. The server side is running a XML-RPC interface, written in Perl, running under lighttpd. For the fetch of pieces those are access via the same web server as real files. Once the slowness hits the XML-RPC calls can timeout because they are so slow. A config save via XML-RPC can take over 5 minutes when this hits and using the child method it is under a minute. I could drop the buffer size of the read. Another option would be to convert to a non-blocking write and keep track of what was written. Then try again. Of course I'll need to change the select logic to go back to waiting after all those buffers have emptied. This would present a problem with devices connecting, but not in the available pool. They would have to wait for the other buffers to be clear before they would be acknowledged.while(1) { for my $socket ($ioset->can_read) { if ($socket == $server) { new_connection($server, $remote_host, $remote_port); }else { next unless exists $socket_map{$socket}; my $remote = $socket_map{$socket}; my $buffer; my $read = $socket->sysread($buffer, 512); if ($read) { $remote->syswrite($buffer); } else { close_connection($socket); } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Many sockets under one select
by RonW (Parson) on Oct 29, 2014 at 17:24 UTC | |
by linxdev (Sexton) on Oct 29, 2014 at 20:10 UTC |