Hi kabeldag,

As per our conversation, I gave your program a try on Windows and Linux both.  For me, the program ran a lot faster under Linux.  I had to change the port from "19" to "77777", since the reserved port 19 wasn't working for me; I don't know if that has any effect on the outcome.

First of all, here's a suggestion I have:  instrument the program so you can see what the transfer rate is.  I added the following code to your program so I could see exactly what the rate was:

# Global variables (added $total_chars and $start_time) my $time_zone_inc=10; my $total_chars = 0; my $start_time; my %sock_client_hash; my $cc=48; # Subroutines (added start_timer() and stop_timer()) sub start_timer() { $start_time = time; $total_chars = 0; } sub stop_timer() { my $stop_time = time; my $nsecs = $stop_time - $start_time; my $cps = sprintf "%.4f", $total_chars / $nsecs; log_event("$total_chars chars / $nsecs seconds = $cps chars / sec\ +n"); } # Added call to start_timer() sub new_socket { my $newclientsock=shift; $newclientsock = $server_sock ->accept; $sel->add($newclientsock); my ($ip,$peer_port)=sock_attrs($newclientsock); $sock_client_hash{$newclientsock->fileno}{ip}=$ip; $sock_client_hash{$newclientsock->fileno}{port}=$peer_port; my $fileNo=$newclientsock->fileno; log_event("New Client connected -> FileNo($fileNo) $ip:$peer_port\ +n"); start_timer(); } # Added increment of $total_chars sub gen_chars { my($wrs) = $_[0]; if($cc==58) { $cc=65; }elsif($cc==91) { $cc=97; }elsif($cc==123) { $cc=48; } $wrs->send(chr($cc)) or close_socket($wrs); $cc++; ++$total_chars; } # Added call to stop_timer() sub close_socket { my $socket=$_[0]; my $sock_ip=$sock_client_hash{$socket->fileno}{ip}; my $sock_peer_port=$sock_client_hash{$socket->fileno}{port}; my $fileNo=$socket->fileno; log_event("Unable to write to -> FileNo($fileNo) $sock_ip:$sock_pe +er_port\n"); if(defined ($socket)) { $sel->remove($socket); $socket->close; log_event("Removed socket -> FileNo($fileNo) $sock_ip:$sock_pe +er_port\n"); stop_timer(); } }
Now I get the following results in Linux and Windows respectively.  (Note that I'm on a laptop, so I used 'localhost' from Linux for all connections, but used my IP address 192.168.2.2 for the first 2 of the 3 Windows connections):
=== Linux === [root@localhost ~]% sock.pl 14:03:28 -> New Client connected -> FileNo(4) 127.0.0.1:44999 14:03:35 -> Unable to write to -> FileNo(4) 127.0.0.1:44999 14:03:35 -> Removed socket -> FileNo(4) 127.0.0.1:44999 14:03:35 -> 6614 chars / 7 seconds = 944.8571 chars / sec 14:03:45 -> Exit called [root@localhost ~]% [root@localhost ~]% sock.pl 14:03:46 -> New Client connected -> FileNo(4) 127.0.0.1:45000 14:04:06 -> Unable to write to -> FileNo(4) 127.0.0.1:45000 14:04:06 -> Removed socket -> FileNo(4) 127.0.0.1:45000 14:04:06 -> 17046 chars / 20 seconds = 852.3000 chars / sec 14:04:13 -> New Client connected -> FileNo(4) 127.0.0.1:45001 14:04:44 -> Unable to write to -> FileNo(4) 127.0.0.1:45001 14:04:44 -> Removed socket -> FileNo(4) 127.0.0.1:45001 14:04:44 -> 26861 chars / 31 seconds = 866.4839 chars / sec 14:04:59 -> Exit called === Windows === C:\Documents and Settings\liverpole\Desktop>sock 14:49:04 -> New Client connected -> FileNo(4) 192.168.2.2:1204 14:49:12 -> Unable to write to -> FileNo(4) 192.168.2.2:1204 14:49:12 -> Removed socket -> FileNo(4) 192.168.2.2:1204 14:49:12 -> 774 chars / 8 seconds = 96.7500 chars / sec 14:49:16 -> New Client connected -> FileNo(4) 192.168.2.2:1205 14:49:39 -> Unable to write to -> FileNo(4) 192.168.2.2:1205 14:49:39 -> Removed socket -> FileNo(4) 192.168.2.2:1205 14:49:39 -> 2374 chars / 23 seconds = 103.2174 chars / sec 14:49:52 -> New Client connected -> FileNo(4) 127.0.0.1:1209 14:50:12 -> Unable to write to -> FileNo(4) 127.0.0.1:1209 14:50:12 -> Removed socket -> FileNo(4) 127.0.0.1:1209 14:50:12 -> 2024 chars / 20 seconds = 101.2000 chars / sec 14:50:35 -> Exit called

So, how do those speeds compare with what you are seeing?


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

In reply to Re: chargen program is too slow / IO::Select socket handle outputting timing issue by liverpole
in thread chargen program is too slow / IO::Select socket handle outputting timing issue by kabeldag

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.