PERL中遇到Your vendor has not defined Fcntl macro F_GETFL解决方法

PERL中遇到Your vendor has not defined Fcntl macro F_GETFL解决方法

今天在WINDOWS下用SOCKET时发现如下错误:(LINUX下正常)

Your vendor has not defined Fcntl macro F_GETFL, used at :/Perl/site/lib/IO/Multiplex.pm line 932.

 

只需要替换Multiplex.pm line 932处函数nonblock:

sub nonblock
{
my $fh = shift;
my $flags = fcntl($fh, F_GETFL, 0)
or die "fcntl F_GETFL: $!\n"
fcntl($fh, F_SETFL, $flags | O_NONBLOCK)
or die "fcntl F_SETFL $!\n"
}

替换为:

use constant WIN32 => $^O =~ /win32/i;

sub nonblock {
my $sock = shift;
if (WIN32) {
my $set_it = "1"
ioctl( $sock, 0x80000000 | (4 << 16) | (ord('f') << 8) | 126, $set_it) || return 0;
} else {
fcntl($sock, F_SETFL, fcntl($sock, F_GETFL, 0) | O_NONBLOCK) || return 0;
}
}

即可。




有兴趣可以访问下我的生活博客: qqmovie.qzone.com

你可能感兴趣的:(PERL中遇到Your vendor has not defined Fcntl macro F_GETFL解决方法)