Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

IO::Select on Windows

by zzspectrez (Hermit)
on Dec 11, 2000 at 09:27 UTC ( #46021=perlquestion: print w/ replies, xml ) Need Help??
zzspectrez has asked for the wisdom of the Perl Monks concerning the following question:

Im curious if anyone has sucessfully used IO::Select on windows. I am trying to use it in some network code. I have been unable to get it to work. I thought I was doing something wrong since I havent used this module before. After messing with this all day today I got the idea to try it on my linux box, and it works fine. So now Im at a loss about what to do now. Basicly, on my win2k machine the loop immediately exits and the program closes. On my linux box, it loops through excepting keyboard data and quits on typing /quit.

If the module can not be made to work..... Is there another way I can get similar functionality??

Here is sniplet of the code.

sub MainLoop { my $self = shift; my $in = \*STDIN; my $net = $self->{'sock'}; my $sel = IO::Select->new($in); $sel->add($net); my @ready = (); DD: while(@ready = $sel->can_read) { foreach my $fh (@ready) { if ($fh == $in) { my $dat = <$fh>; chomp $dat; last DD if ($dat eq '/quit'); }elsif ($fh == $net) { } } } $self->logoff; close $self->{'sock'}; }

Thanks!
zzSPECTREz

Comment on IO::Select on Windows
Download Code
Re: IO::Select on Windows
by a (Friar) on Dec 11, 2000 at 10:23 UTC
    Just a guess, but there are a great many 'issues' w/ select (fork and others) on winxx boxes. I imagine you've found one. There's a winxx faq (usually) w/ the perl distro that may have the real answer for you ... mine's in perl\html\Perl-Win32

    a

Re: IO::Select on Windows
by MeowChow (Vicar) on Dec 11, 2000 at 13:54 UTC
    IO::Select works fine under both Windows NT and 2000 (I haven't actually tried it under 98, but I assume it would work there as well). One caveat, however, is that non-blocking mode is screwed up unless you do some nasty work-arounds.
Re: IO::Select on Windows
by Fastolfe (Vicar) on Dec 11, 2000 at 18:52 UTC
    Note that under Win32, I don't know that any implementation of select works against all file handles. Sockets yes, files no. I don't know where STDIN lies in this, but I suspect its nature may make it unselectable under Win32 as well.

      Yep, after some looking. I found this to be the case. According to perlport man page select is only implemented on sockets on the Win32 port. This sucks! So I guess I will have to find another way to handle this.

      thanks!
      zzSPECTREz

Re: IO::Select on Windows
by gharris (Beadle) on Dec 11, 2000 at 21:34 UTC
    I was trying to do something almost exactly like this a while back, and came to the conclusion (after some discussion here) that Windows can only select on sockets.

    --Glenn

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://46021]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2014-11-26 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (169 votes), past polls