Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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'}; }


Replies are listed 'Best First'.
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.


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


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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://46021]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2018-05-21 19:42 GMT
Find Nodes?
    Voting Booth?