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
"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
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
> $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
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
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:
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
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
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
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,
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
11 matches
Mail list logo