IO:Select - what did I do wrong?

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default IO:Select - what did I do wrong?

    Can't see what's wrong with this code... It's running under windows XP with
    activestate perl 5.6.1 (which may well be part of the issue...).

    The following code gives me an error:
    Error in select: Bad file descriptor at io_select_test.pl line 11.

    ....However, it is pretty much straight out of the man pages.

    The problem I am trying to solve is how to read from a bunch of sockets with
    a blocking select, but also read from Stdin. I guess I could make my select
    only block for 1/2 sec or so and then poll stdin, but there must be
    something better than this? (in fact I seem to have some probs doing
    non-blocking input from stdin under win32... Is this normal, does it work
    for other people...)
    >>>>>
    #!perl -w
    use strict;
    use warnings;
    use IO::Socket;
    use IO::Select;

    my $r = IO::Select->new(\*STDIN);

    $|=1;

    my ($rr) = IO::Select->select( $r )
    or die "Error in select: $!";

    print "Success";



    Ed W Guest

  2. Similar Questions and Discussions

    1. #25474 [Bgs]: posting arrays from a select box with multiple select is not working properly
      ID: 25474 User updated by: fmuller at cisco dot com -Summary: apache2filter: posting from a multiple select box is not...
    2. #25474 [Fbk->Opn]: posting arrays from a select box with multiple select is not working properly
      ID: 25474 User updated by: fmuller at cisco dot com Reported By: fmuller at cisco dot com -Status: Feedback...
    3. #25474 [Opn->Fbk]: posting arrays from a select box with multiple select is not working properly
      ID: 25474 Updated by: sniper@php.net Reported By: fmuller at cisco dot com -Status: Open +Status: ...
    4. field seperator in select / wrong statement ?
      Hi, is there a way to set a field-seperator for the output? I have to get a row of fields which also can contain spaces. So the blank for the...
    5. SELECT DISTINCT + ORDER BY gives ERROR 145: ORDER BY items mustappear in the select list if SELECT DISTINCT is specified.
      Dan, You should be able to do this: SELECT Id, FaxID, ReceivedTime, Pages FROM ( SELECT DISTINCT .Id AS Id,
  3. #2

    Default Re: IO:Select - what did I do wrong?

    In article <Ac28b.12779$Os1.86997@news.easynews.com>,
    Ed W <dodgynewsgroups@ewildgoose.demon.co.uk> wrote:

    : Can't see what's wrong with this code... It's running under windows XP with
    : activestate perl 5.6.1 (which may well be part of the issue...).
    :
    : The following code gives me an error:
    :
    : [my $r = IO::Select->new(\*STDIN);]
    :
    : Error in select: Bad file descriptor at io_select_test.pl line 11.

    According to the perlport manpage:

    select RBITS,WBITS,EBITS,TIMEOUT

    Only implemented on sockets. (Win32, VMS)

    Hope this helps,
    Greg
    --
    Although the South would have preferred any honorable compromise to the frat-
    ricidal war which has taken place, she now accepts in good faith its consti-
    tutional results, and receives without reserve the amendment which has already
    been made to the constitution for the extinction of slavery. -- Robert E. Lee
    Greg Bacon Guest

  4. #3

    Default Re: IO:Select - what did I do wrong?


    "Greg Bacon" <gbacon@hiwaay.net> wrote in message
    news:vm1cut68iasm85@corp.supernews.com...
    > In article <Ac28b.12779$Os1.86997@news.easynews.com>,
    > Ed W <dodgynewsgroups@ewildgoose.demon.co.uk> wrote:
    >
    > : Can't see what's wrong with this code... It's running under windows XP
    with
    > : activestate perl 5.6.1 (which may well be part of the issue...).
    > :
    > : The following code gives me an error:
    > :
    > : [my $r = IO::Select->new(\*STDIN);]
    > :
    > : Error in select: Bad file descriptor at io_select_test.pl line 11.
    >
    > According to the perlport manpage:
    >
    > select RBITS,WBITS,EBITS,TIMEOUT
    >
    > Only implemented on sockets. (Win32, VMS)
    >
    > Hope this helps,
    Ahh nuts. Thanks. I hadn't thought to look in the perlport manpage.

    Any suggestions for the best way to do this? I thought either:

    a) writing a socket interface into my code
    b) converting to "wheel" type code, or perhaps wxwindows (since my GUI app
    will be in this)
    c) run a blocking select with timeout and check stdin occasionally

    Anything else I should look at...?

    Ta

    Ed W


    Edward Wildgoose Guest

  5. #4

    Default Re: IO:Select - what did I do wrong?

    In article <rJ28b.981019$Bf5.140355@news.easynews.com>,
    Edward Wildgoose <Ed+nospam@ewildgoose.demon.co.uk@> wrote:

    : [...]
    :
    : Anything else I should look at...?

    Install an operating system? :-) :-) :-)

    Greg
    --
    In a literary light, if UNIX is the Great Novel, Perl is the Cliffs Notes.
    -- Thomas Scoville
    Greg Bacon Guest

  6. #5

    Default Re: IO:Select - what did I do wrong?

    > : Anything else I should look at...?
    >
    > Install an operating system? :-) :-) :-)
    Yeah, fair enough....

    ....It's going to be used by other people though, and the spec indicates MS
    windows....

    ....oh well

    Thanks

    Ed W


    Ed W Guest

  7. #6

    Default Re: IO:Select - what did I do wrong?

    In article <0d58b.19738$Os1.159146@news.easynews.com>,
    Ed W <dodgynewsgroups@ewildgoose.demon.co.uk> wrote:

    : > Install an operating system? :-) :-) :-)
    :
    : Yeah, fair enough....
    :
    : ...It's going to be used by other people though, and the spec indicates MS
    : windows....
    :
    : ...oh well

    Have you considered feeding STDIN to a socket and adding the target
    socket to your fd_set? Lucky for you that recent versions of perl on
    Win32 have fork emulation.

    Greg
    --
    Government seems to operate on the principle that if even one individual
    is incapable of using his freedom competently, no one can be allowed to
    be free.
    -- Harry Browne
    Greg Bacon Guest

  8. #7

    Default Re: IO:Select - what did I do wrong?

    In article <0d58b.19738$Os1.159146@news.easynews.com>, [email]dodgynewsgroups@ewildgoose.demon.co.uk[/email] says...
    >> : Anything else I should look at...?
    >>
    >> Install an operating system? :-) :-) :-)
    >
    >Yeah, fair enough....
    >
    >...It's going to be used by other people though, and the spec indicates MS
    >windows....
    Try cygwin. [url]http://www.cygwin.com/[/url]

    It's perl port runs fine with your test program.

    --
    Heinrich Mislik
    Zentraler Informatikdienst der Universitaet Wien
    A-1010 Wien, Universitaetsstrasse 7
    Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140

    Heinrich Mislik Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139