Nonblocking Filehandles under Windows

Discussion in 'Perl Misc' started by Angus, Aug 29, 2003.

  1. Angus

    Angus Guest

    Hi,

    I am running ActiveState ActivePerl 5.8 under Windows NT and I'd like to use
    a non-blocking file handle to do socket I/O. I tried the following:

    use POSIX;
    fcntl ($socket, F_SETFL(), O_NONBLOCK());

    The error message I get is "Your vendor has not defined POSIX macro
    F_SETFL". Does it mean that this is not supported in the Windows
    environment? Any advice would be appreciated. Thanks in advance.

    Angus
    Angus, Aug 29, 2003
    #1
    1. Advertising

  2. Angus

    Rocco Caputo Guest

    On Fri, 29 Aug 2003 11:38:01 -0400, Angus wrote:
    > Hi,
    >
    > I am running ActiveState ActivePerl 5.8 under Windows NT and I'd like to use
    > a non-blocking file handle to do socket I/O. I tried the following:
    >
    > use POSIX;
    > fcntl ($socket, F_SETFL(), O_NONBLOCK());
    >
    > The error message I get is "Your vendor has not defined POSIX macro
    > F_SETFL". Does it mean that this is not supported in the Windows
    > environment? Any advice would be appreciated. Thanks in advance.


    use IO::Handle;
    $socket->blocking(0);

    --
    Rocco Caputo - - http://poe.perl.org/
    Rocco Caputo, Aug 29, 2003
    #2
    1. Advertising

  3. Also sprach Angus:

    > I am running ActiveState ActivePerl 5.8 under Windows NT and I'd like to use
    > a non-blocking file handle to do socket I/O. I tried the following:
    >
    > use POSIX;
    > fcntl ($socket, F_SETFL(), O_NONBLOCK());
    >
    > The error message I get is "Your vendor has not defined POSIX macro
    > F_SETFL". Does it mean that this is not supported in the Windows
    > environment?


    This constant is from fcntl.h so I would rather expect it in Fcntl.pm and
    not POSIX.pm. Try

    use Fcntl qw/F_SETFL/;

    Tassilo
    --
    $_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
    pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
    $_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
    Tassilo v. Parseval, Aug 29, 2003
    #3
  4. Angus

    Angus Guest

    Thanks for everyone's suggestions.

    I tried the following as you suggested:

    use IO::Socket::INET;
    use Fcntl qw/F_SETFL/;
    $server = IO::Socket::INET->new(LocalPort => 1919, Proto => "udp");
    fcntl ($server, F_SETFL, O_NONBLOCK);
    close ($server);

    I got the same error "Your vendor has not defined Fcntl macro F_SETFL".
    (BTW, I used POSIX because I was just following the example in one of the
    O'Reilly books.)

    Then I tried the following:

    use IO::Socket::INET;
    $server = IO::Socket::INET->new(LocalPort => 1919, Proto => "udp",
    Blocking=>0);
    $bytes_read = sysread($server, $buf, 1500);
    print "I am not blocked.\n";
    close ($server);

    which should work according to the documentation. The program runs but the
    sysread is still blocked. What is wrong? Thanks again.

    Angus


    "Purl Gurl" <> wrote in message
    news:...
    > Angus wrote:
    >
    > > I am running ActiveState ActivePerl 5.8 under Windows NT and I'd like to

    use
    > > a non-blocking file handle to do socket I/O. I tried the following:

    >
    > > use POSIX;
    > > fcntl ($socket, F_SETFL(), O_NONBLOCK());

    >
    > > The error message I get is "Your vendor has not defined POSIX macro
    > > F_SETFL". Does it mean that this is not supported in the Windows
    > > environment?

    >
    > No, your "this" means POSIX cannot export "F_SETFL" to main.
    >
    > Why are using POSIX and clearly making mention of the Fcntl module?
    >
    > You know of Fcntl yet use POSIX. Rather contradictory, yes?
    >
    > Beneath my signature is an easy way to check contents of main.
    > Look under exporter. However, it is even easier to simply open
    > a module and note what is exported.
    >
    > Run this as a cgi or results will scroll past faster than you can read.
    >
    >
    > Purl Gurl
    > --
    >
    > #!perl
    >
    > print "Content-type: text/plain\n\n";
    >
    > use Fcntl qw/F_SETFL/;
    >
    > foreach $key_name (keys %main::)
    > { print "$key_name \n"; }
    >
    > exit;
    >
    >
    > PRINTED RESULTS:
    > ________________
    >
    > key_name
    > AutoLoader::
    > STDOUT
    > @
    > ARGV
    > STDIN
    > 
    > attributes::
    > DB::
    > _<C:/APACHE/lib/auto/Fcntl/Fcntl.dll
    > _<..\xsutils.c
    > _<perllib.c
    > UNIVERSAL::
    > _<dl_win32.c
    > 
    > <none>::
    > DynaLoader::
    > Fcntl::
    > 
    > SIG
    > Exporter::
    > F_SETFL
    > Win32::
    > BEGIN
    > stderr
    > INC
    > _
    > !
    > "
    > _<.\win32.c
    > _<Fcntl.c
    > $
    > stdout
    > IO::
    > ENV
    > Carp::
    > stdin
    > CORE::
    > /
    > XSLoader::
    > 0
    > _<..\universal.c
    > STDERR
    > main::
    Angus, Aug 29, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KimTaehwan

    setSoTimeout in nonblocking mode?

    KimTaehwan, Nov 16, 2003, in forum: Java
    Replies:
    0
    Views:
    1,136
    KimTaehwan
    Nov 16, 2003
  2. nonblocking sockets

    , Apr 7, 2006, in forum: Java
    Replies:
    2
    Views:
    1,092
    Gordon Beaton
    Apr 8, 2006
  3. Peter Ammon

    nonblocking read()

    Peter Ammon, Nov 16, 2004, in forum: Python
    Replies:
    3
    Views:
    556
    Donn Cave
    Nov 17, 2004
  4. anki
    Replies:
    3
    Views:
    305
  5. Jean-Francois Nadeau

    Windows - Socket - Connect - Nonblocking

    Jean-Francois Nadeau, Jul 6, 2004, in forum: Ruby
    Replies:
    4
    Views:
    233
    Jean-Francois Nadeau
    Jul 8, 2004
Loading...

Share This Page