Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Re: Re: Re: Activeperl 5.6 fork() doesn't friggin work

by jtx (Initiate)
on Apr 18, 2002 at 18:20 UTC ( [id://160297]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Activeperl 5.6 fork() doesn't friggin work
in thread Activeperl 5.6 fork() doesn't friggin work

What I have been able to do, though it is a cheap hack and will probably have to be re-written if I want this to be a serious program, is taken your idea of using a while loop and somewhat modifying the server/client. This is the modified client, and it works, though like I said, I think it's pretty cheesy:
#!/usr/bin/perl use IO::Socket; # Make our connections my $ns1 = new IO::Socket::INET (PeerAddr => 'ns1', PeerPort => 1200, Proto => 'tcp' ) or die "Couldn't create socket: $!\n" +; my $line; my $count = 0; my $domain = 'hello.com'; my $ipaddress = '192.168.0.1'; while ($line ne 'CAIO') { if ($count == 0) { print $ns1 "HELO\n"; $count++; } elsif ($count == 1) { print $ns1 "dom:$domain\n"; $count++; } elsif ($count == 2) { print $ns1 "ipaddr:$ipaddress\n"; $count++; } elsif ($count == 3) { print $ns1 "addzone\n"; $count++; } sleep(1); chomp($line = <$ns1>); print "$line\n"; } close($ns1);
As you might have gathered, the server is a name server, and this program was created to add zones via sockets. It's irrelevant to me at this point whether or not BIND supports this natively - This is just a good way for me to practice using Sockets and TK, and make my boss happy while I write programs that will eventually end up being my replacement :)

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Activeperl 5.6 fork() doesn't friggin work
by premchai21 (Curate) on Apr 19, 2002 at 01:57 UTC

    Or:

    my (@cmds) = ("HELO", "dom:$domain", "ipaddr:$ipaddress", "addzone"); while (@cmds) { print $ns1 shift(@cmds), "\n"; $line = <$ns1>; # don't need the sleep; # the read should block until # a line is available. defined($line) or last; # quit if connection closed # (could die instead) print $line; # don't need \n now, $line # not chomped ($line =~ /^CAIO$/) and last; # $ can handle trailing # newline, with no # significant speed penalty # (should be optimized by # regex engine) }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://160297]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2025-04-25 16:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.