develooper Front page | perl.perl5.porters | Postings from November 1999

IO::Select issue?

Thread Next
Marc Pavese
November 16, 1999 08:50
IO::Select issue?
Message ID:

I posted the below message to comp.lang.perl.misc a day or two ago,
and got no responses. Since the "fix" I found to my problem involved
editing one line of IO::Socket, I'm forwarding this to you to ask if
you have any advice. I'm not at all sure that my fix was right. If so,
great. If not, I'm hoping you can set me straight.

Thanks very much,


--text follows this line--

I am writing some perl client/server code that uses IO::Select
(version 1.13), and I am having a problem with the IO::Select::exists

At one point in my code, I call $select->exists on a client socket
to determine whether or not it has been terminated. I usually get the
following warning when I call it on a client which is in fact gone:

Use of uninitialized value at
/usr/lib/perl5/5.00503/ppc-linux/IO/ line 49.

The following change to line 49 of IO::Select makes the error

--- /usr/lib/perl5/5.00503/ppc-linux/IO/     Thu Jul 23 23:45:41 1998
+++   Tue Oct 19 18:39:59 1999
@@ -46,7 +46,7 @@
 sub exists
  my $vec = shift;
- $vec->[$vec->_fileno(shift) + FIRST_FD];
+ $vec->[ ($vec->_fileno(shift) || 0) + FIRST_FD];

What is happening is that $vec->_filenoo is returning undef on the
passed in socket. When you try to add undef with FIRST_FD, you get the

Could someone tell me if this change makes sense at all?  I checked,
and in the only other place in IO::Socket where _fileno is used (in
the _update subroutine), the case of undef is specifically tested for
so I guess undef is not an unexpected return value from _fileno.

With the change, my code seems to work as intended. Maybe I am
misunderstanding the purpose of IO::Select::exists though. I don't
have much experience with tcp sockets. I can try to provide a
minimal test-case as well, if that might help.

Thanks for any advice,


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About