Nonblocking Filehandles under Windows

A

Angus

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
 
R

Rocco Caputo

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);
 
T

Tassilo v. Parseval

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
 
A

Angus

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,086
Latest member
ChelseaAmi

Latest Threads

Top