strat has asked for the wisdom of the Perl Monks concerning the following question:
I just tried the Example gap5.pl in "A Multiplexed Client" from "Network Programming with Perl" from "Lincoln D. Stein" under Win2k, but it doesn't work.
Perl: Activestate Built 631
OS: Windows 2000 Workstation
IO-Select: $VERSION = "1.14";
The while-loop is executed, but $readers->can_read never returns anything, so the for my $handle - loop is never started.#! perl use strict; use warnings; use IO::Socket; use IO::Select; use constant BUFSIZE => 1024; my $host = "localhost"; my $port = 80; my $socket = IO::Socket::INET->new("$host:$port") or die $@; my $readers = IO::Select->new() or die "Error: can't create IO::Select read object\n"; $readers->add(\*STDIN); $readers->add($socket); my $buffer = ""; print "starting loop\n"; while(1){ my @ready = $readers->can_read; for my $handle (@ready) { print STDERR "STDIN ready\n"; if ($handle eq \*STDIN) { print "STDIN ready\n"; if (sysread(STDIN, $buffer, BUFSIZE) > 0) { syswrite($socket, $buffer); } else { $socket->shutdown(1); } } if ($handle eq $socket) { print STDERR "SOCKET ready\n"; if (sysread($socket, $buffer, BUFSIZE) > 0) { syswrite (STDOUT, $buffer); } else { warn "Connection closed by foreign host\n"; exit 0; } } # if } # for @ready } # forever
Lincoln Stein wrote in the book that ... Because this script doesn't rely on either forking or threading, it runs on practically all operation systems where Perl is available, including the Macintosh.
Does this code really not work with Win2k and AS 631, or do I miss something?
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiplexed TCP-Client (from: Networkprogramming with Perl)
by kvale (Monsignor) on Jul 27, 2002 at 15:22 UTC | |
|
Re: Multiplexed TCP-Client (from: Networkprogramming with Perl)
by PodMaster (Abbot) on Jul 28, 2002 at 07:32 UTC | |
|
•Re: Multiplexed TCP-Client (from: Networkprogramming with Perl)
by merlyn (Sage) on Jul 27, 2002 at 15:12 UTC | |
by mitd (Curate) on Jul 27, 2002 at 16:57 UTC | |
by merlyn (Sage) on Jul 27, 2002 at 17:06 UTC | |
by thor (Priest) on Jul 27, 2002 at 15:51 UTC | |
by strat (Canon) on Jul 27, 2002 at 22:03 UTC |