Re: [SLUG] Perl IO::Socket question

2007-10-11 Thread Shane Anderson
You're a champ Scott, works great now :) [EMAIL PROTECTED]:~$ telnet localhost Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. hello Doesn't work! - hello - The command should appear before this.Connectionclosed by foreign host. Thanks, Shane On 12/10/2007, Scott Rage

Re: [SLUG] Perl IO::Socket question

2007-10-11 Thread Scott Ragen
"Shane Anderson" <[EMAIL PROTECTED]> wrote on 12/10/2007 09:45:02 AM: > Hi, > > I've removed the if statement that checks the hash so now the code > looks like this: > while (my ($client, $client_address) = $server->accept()) { > $client->autoflush(1); > my ($port, $packed_ip) = sockaddr

Re: [SLUG] Perl IO::Socket question

2007-10-11 Thread Shane Anderson
Hi, I've removed the if statement that checks the hash so now the code looks like this: while (my ($client, $client_address) = $server->accept()) { $client->autoflush(1); my ($port, $packed_ip) = sockaddr_in($client_address); my $client_ip = inet_ntoa($packed_ip); my $stamp = ×tamp

Re: [SLUG] Perl IO::Socket question

2007-10-11 Thread Scott Ragen
> $client->recv($recv, 128); > chomp($recv); > > if (exists($commands{$recv})) { > $client->send("Works! Received: $recv"); > } else { > $client->send("Doesn't work! We received this: $recv"); > } > } > > The code above doesn't print out anything for $recv, how

Re: [SLUG] Perl IO::Socket question

2007-10-11 Thread Shane Anderson
Thanks for the buffering explanation, but unfortunately it's still not working. On 11/10/2007, Amos Shapira <[EMAIL PROTECTED]> wrote: > > On 11/10/2007, Shane Anderson <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I don't believe it's IO buffering as $recv prints out fine if I don't do > a > > c

Re: [SLUG] Perl IO::Socket question

2007-10-11 Thread Amos Shapira
On 11/10/2007, Shane Anderson <[EMAIL PROTECTED]> wrote: > > Hi, > > I don't believe it's IO buffering as $recv prints out fine if I don't do a > chomp();, but I'll give it a shot. If the socket is in line buffering then maybe the newline at the end of $recv causes the buffer to be flushed. Try:

Re: [SLUG] Perl IO::Socket question

2007-10-10 Thread Tony Sceats
I would have thought the following makes more sense if (defined($recv})) { chomp($recv); $client->send("Works! Received: $recv"); } where's %commands coming from? On 10/11/07, Shane Anderson <[EMAIL PROTECTED]> wrote: > > Hi All, > > I'm attempting to learn IO::Socket and have hit a

Re: [SLUG] Perl IO::Socket question

2007-10-10 Thread Shane Anderson
Hi, I don't believe it's IO buffering as $recv prints out fine if I don't do a chomp();, but I'll give it a shot. Thanks, Shane On 11/10/2007, David Lloyd <[EMAIL PROTECTED]> wrote: > > > Shane, > > > while (my ($client, $client_address) = $server->accept()) { > > my ($port, $packed_ip) = s

Re: [SLUG] Perl IO::Socket question

2007-10-10 Thread Shane Anderson
Hi, %commands defined much earlier in the program and I want to see if $recv matches a key in that array. That isn't the issue i'm having through. It doesn't matter if the logic fails, regardless $recv suddenly has nothing in it if I perform a chomp() on it. Thanks, Shane On 11/10/2007, Tony Sc

Re: [SLUG] Perl IO::Socket question

2007-10-10 Thread David Lloyd
Shane, while (my ($client, $client_address) = $server->accept()) { my ($port, $packed_ip) = sockaddr_in($client_address); my $client_ip = inet_ntoa($packed_ip); my $stamp = ×tamp; print LOGFILE "$stamp - Client ($client_ip) connected.\n" if $DEBUG == 1; $client->recv($recv,

[SLUG] Perl IO::Socket question

2007-10-10 Thread Shane Anderson
Hi All, I'm attempting to learn IO::Socket and have hit a snag with this bit of code: while (my ($client, $client_address) = $server->accept()) { my ($port, $packed_ip) = sockaddr_in($client_address); my $client_ip = inet_ntoa($packed_ip); my $stamp = ×tamp; print LOGFILE "$stamp