Thanks tachyon. All i want to do is connect to my server and send off a file of test commands one by one ,capturing the incoming replies so that they can be logged and processed and more commands added to the send queue depending on the incoming.
I guess the closest analogy would be an IRC client where i can receive messages in reply to my client or just receive a message from another client connected to the same server.
All the client examples i can find only deal with a very simple client thats either synchromous or only handles sends
I had this before and it works great.
die "can't fork: $!" unless defined($kidpid = fork());
if ($kidpid) { # We are the parent. Handle incoming
my $header;
my $body;
while(1)
{
while (defined sysread $handle,$header,9,0)
{
print $header,"\n";
if($header =~ m/([A-Z]{4})(\d{5})/)
{
my $messagetype = $1;
if($2 != 00000)
{
$2 =~ m/0+(\d+)/; #remove
sysread $handle,$body,$1,0; #receive am
+ount specified in header
}
check_header_type $messagetype, $body, $handle; #do t
+hings with this message
}
}
}
kill("TERM" => $kidpid); # send SIGTERM to child
}
###############################################
# Child Process
###############################################
else {
# Child. handle all sends
while ($line = <INPUTFILE>) {
chomp $line;
if(!($line =~ m/\A#/)) #check for '#' in file as comment s
+ign
{syswrite DEBUG, "Got Line\n";
my $bod = add_header($line);
syswrite $handle, $bod;
}
}
}
but im stuck in cygwin, no debugging support, and passing new messages to the child process to send is starting to complicate things (from what i know)just for hacked up client.
So really im trying to get the above working smoothly without fork.
thanks
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.