Hello,

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";

#! 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
The while-loop is executed, but $readers->can_read never returns anything, so the for my $handle - loop is never started.

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"


In reply to Multiplexed TCP-Client (from: Networkprogramming with Perl) by strat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.