Can someone please give me some pointers or links for writing a simple client that i want to use for testing to put a server through its paces.(on windows, which means no
IO::Multiplex or
IO::Event).
The easiest has been using fork under cygperl but then that rules out the use of a debugger as well as making it hard to add messages to the outgoing queue in the other process.
I tried something crude like this as well but after a couple of writes it never reaches the write sub again even with no reads coming in.
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;
}
}
I just need it to tbe async and recieve and send messages in no particular order. Thanks for any help.
Cheers
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.