develooper Front page | perl.perl5.porters | Postings from February 2003

[PATCH IO/Socket/INET.pm] Blocking option ignored

Thread Next
From:
Dave Mitchell
Date:
February 18, 2003 13:49
Subject:
[PATCH IO/Socket/INET.pm] Blocking option ignored
Message ID:
20030218214545.C18547@fdgroup.com
Currently IO::Socket::INET->new(Blocking => 0, ....)
silently fails to set non-blocking, because it attempts to do the fcntl
(or whatever) on the socket before the socket's been created. This patch
fixes that.
(Only tested on Solaris + Linux; I know nothing about those esoteric
OSes from Redmond.)

Dave.

-- 
Any [programming] language that doesn't occasionally surprise the
novice will pay for it by continually surprising the expert.
 - Larry Wall


--- ext/IO/lib/IO/Socket/INET.pm-	Tue Feb 18 21:26:05 2003
+++ ext/IO/lib/IO/Socket/INET.pm	Tue Feb 18 21:27:42 2003
@@ -129,8 +129,6 @@
 			or return _error($sock, $!, $@);
     }
 
-    $sock->blocking($arg->{Blocking}) if defined $arg->{Blocking};
-
     $proto ||= (getprotobyname('tcp'))[2];
 
     my $pname = (getprotobynumber($proto))[0];
@@ -149,6 +147,11 @@
 	$sock->socket(AF_INET, $type, $proto) or
 	    return _error($sock, $!, "$!");
 
+        if (defined $arg->{Blocking}) {
+	    defined $sock->blocking($arg->{Blocking})
+		or return _error($sock, $!, "$!");
+	}
+
 	if ($arg->{Reuse} || $arg->{ReuseAddr}) {
 	    $sock->sockopt(SO_REUSEADDR,1) or
 		    return _error($sock, $!, "$!");

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About