Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I just need it to tbe async and recieve and send messages in no particular order. Thanks for any help.sub read_incoming { while (defined sysread $_[0],$header,9,0) # Get header for the cor +rect body length to call next; { if($header =~ m/([A-Z]{4})0+(\d{5})/) { my $messagetype = $1; sysread $_[0],$body,$2,0;#receive ng } } } sub write_outgoing { if(defined(my $line = shift(@g_queue))) { syswrite $_[0] ,$line; } } while(1) { ($r_ready, $w_ready) = IO::Select->select($read_set, $write_set, undef, $timeout); foreach my $rhandle (@$r_ready) #handle reads { read_incoming $rhandle; } foreach my $whandle(@$w_ready) #handle writes { write_outgoing $whandle; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trying to write simple sockets client on Windows
by tachyon (Chancellor) on Apr 14, 2004 at 03:29 UTC | |
by Anonymous Monk on Apr 14, 2004 at 06:03 UTC | |
by Anonymous Monk on Apr 14, 2004 at 05:34 UTC | |
|
Re: trying to write simple sockets client on Windows
by NetWallah (Canon) on Apr 14, 2004 at 03:28 UTC |