BEGIN {
if( $^O eq 'MSWin32' ) {
*EWOULDBLOCK = sub () { 10035 };
*EINPROGRESS = sub () { 10036 };
*IO::Socket::blocking = sub {
my ($self, $blocking) = @_;
my $nonblocking = $blocking ? "0" : "1";
ioctl($self, 0x8004667e, $nonblocking);
};
} else {
require Errno;
import Errno qw(EWOULDBLOCK EINPROGRESS);
}
}
......
my $sock = IO::Socket::INET->new(Proto=>'tcp') or die "socket: $@";
defined($sock->blocking(0)) or die "Couldn't set nonblocking: $^E";
$sock->connect($sockaddr) or
$! == EWOULDBLOCK or $! == EINPROGRESS or
die sprintf "connect: %d, %s", $!, $^E;
It would be nice to be able to replace that BEGIN block with a simple
'use Errno qw(EWOULDBLOCK EINPROGRESS);'
I found the ioctl thingy inside of LWP::Parrallel::Protocol::http, where
it was something like:
my $set_it = "1";
my $ioctl_val = 0x80000000 | (4 << 16) | (ord('f') << 8) | 126;
ioctl ($socket, $ioctl_val, $set_it);
--
tr/`4/ /d, print "@{[map --$| ? ucfirst lc : lc, split]},\n" for
pack 'u', pack 'H*', 'ab5cf4021bafd28972030972b00a218eb9720000';
> It would be nice to be able to replace that BEGIN block with a simple
> 'use Errno qw(EWOULDBLOCK EINPROGRESS);'
I am not sure what you mean by "...due to the fact sockets are a separate library"
Bur the first part should be integrated into IO.xs
Patches welcome
Graham.