Skip Menu |

This queue is for tickets about the IO CPAN distribution.

Report information
The Basics
Id: 46405
Status: rejected
Priority: 0/
Queue: IO

People
Owner: Nobody in particular
Requestors: KNI [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] return value on non blocking connect
The attached patch make IO::Socket::connect behavior similar to CORE::connect with $sock->blocking(0);
Subject: IO_Socket.patch
--- lib/IO/Socket.pm Wed May 27 12:20:07 2009 +++ lib/IO/Socket.pm_new Wed May 27 12:20:01 2009 @@ -142,7 +142,11 @@ $! = $err if $err; - $err ? undef : $sock; + if (!$blocking and $!{EINPROGRESS} or $!{EWOULDBLOCK}) { + undef; + } else { + $err ? undef : $sock; + } } # Enable/disable blocking IO on sockets.
Subject: Re: [rt.cpan.org #46405] [PATCH] return value on non blocking connect
Date: Wed, 27 May 2009 07:18:13 -0500
To: bug-IO [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
connect was specifically written to still return $sock when using non blocking, that is the purpose of elsif ($blocking || !($!{EINPROGRESS} || $!{EWOULDBLOCK})) { $err = $!; $@ = "connect: $!"; } your patch would be the same as changing that code to be else { $err = $!; $@ = "connect: $!"; } The point of returning $sock when a non blocking connection is pending is so that code can use simple trust of the return to determine if there is an error that needs handling. When doing non-blocking connect EINPROGRESS and EWOULDBLOCK are not errors, but expects. The callers code would then go on to detecting when the connect is complete using select Graham.
It is even better than CORE::connect! Thanks