Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion IO::Socket::INET hostname restrictions?

Received: by 10.68.36.6 with SMTP id m6mr3378959pbj.4.1323302587573;
        Wed, 07 Dec 2011 16:03:07 -0800 (PST)
MIME-Version: 1.0
Path: lh20ni81150pbb.0!nntp.google.com!news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!217.73.144.45.MISMATCH!feeder2.ecngs.de!ecngs!feeder.ecngs.de!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 07 Dec 2011 18:03:06 -0600
Newsgroups: comp.lang.perl.misc
Subject: Re: IO::Socket::INET hostname restrictions?
References: <4edae754$3$fuzhry+tra$mr2ice@news.patriot.net> <Nf-dnZw65uvr7kDTnZ2dnUVZ8tydnZ2d@bt.com> <4edf82d9$21$fuzhry+tra$mr2ice@news.patriot.net> <dfGdndQWk9hVEULTnZ2dnUVZ7rqdnZ2d@bt.com>
From: Ben Morrow <b...@morrow.me.uk>
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: ma...@anubis.morrow.me.uk (Ben Morrow)
Date: Wed, 7 Dec 2011 23:54:09 +0000
Message-ID: <1ua5r8-ac2.ln1@anubis.morrow.me.uk>
Lines: 42
X-Usenet-Provider: http://www.giganews.com
X-AuthenticatedUsername: NoAuthUser
X-Trace: sv3-6W3s8xwBWJ4+yCaM6dkp6rgox1m2lVg+sCrGOm/PkK43FvIOrD5BwGh8lI3mCq6PMcpgny6zD7AJ32x!vIziyMZB8hczj/6H1D1GvkShrARl6AOkp+K2QvbExwVXWfWqAZnlMTqxdrsOpBilsyksvkQ=
X-Complaints-To: abuse@btinternet.com
X-DMCA-Complaints-To: ab...@btinternet.com
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 2851
Content-type: text/plain; charset=UTF-8


Quoth Ben Morrow <b...@morrow.me.uk>:
> 
> I do intend to report this as a bug in IO::Socket, when I get round to
> it.

If and when you get gcc working, would you be able to test this patch?
You would need to download and unpack the IO-1.25 tarball from CPAN,
apply the patch, and verify that it both passes 'make test' and gives a
more sensible error in the situation we've been discussing. 

If you don't want to install the patched version you can use 'perl
-Mblib' from within the build directory to test the built-but-not-
installed modules. If you do want to install it, it should be perfectly
safe to install with 'make install': it will simply overwrite the IO::*
modules which came with your perl with newer versions.

Ben

diff -ur IO-1.25/lib/IO/Socket.pm IO/lib/IO/Socket.pm
--- IO-1.25/lib/IO/Socket.pm	2009-05-14 00:47:42.000000000 +0100
+++ IO/lib/IO/Socket.pm	2011-12-07 16:35:52.859688028 +0000
@@ -122,12 +122,12 @@
 		$err = $! || (exists &Errno::ETIMEDOUT ? &Errno::ETIMEDOUT : 1);
 		$@ = "connect: timeout";
 	    }
-	    elsif (!connect($sock,$addr) &&
-                not ($!{EISCONN} || ($! == 10022 && $^O eq 'MSWin32'))
-            ) {
-		# Some systems refuse to re-connect() to
-		# an already open socket and set errno to EISCONN.
-		# Windows sets errno to WSAEINVAL (10022)
+	    elsif (!getpeername($sock)) {
+                if ($!{ENOTCONN}) {
+                    # this read will fail, but will give us the error
+                    # from connect(2) in $!
+                    sysread $sock, my $tmp, 1;
+                }
 		$err = $!;
 		$@ = "connect: $!";
 	    }