kann keine 2 Sockets connecten: "Operation now in progress" (IO::Socket::INET->new)
Hallo,
ich habe folgendes Problem.
Ich möchte zu einem Host eine TCP-Verbindung aufbauen. Wenn dies nicht
geht, dann möchte ich versuchen, zu einem anderen Host eine Verbindung
aufzubauen. Das ist doch eine absolut triviale Aufgabe .... kriegs aber
nicht hin:
____________________________________________________________ ____
#!/usr/bin/perl -w
use strict;
use IO::Socket qw(:DEFAULT :crlf);
my $socket1 = IO::Socket::INET->new( PeerAddr => "10.11.12.13",
PeerPort => 123,
Proto => 'tcp',
Timeout => 1);
print "Can't connect to host1: $!\n" if (! $socket1);
my $socket2 = IO::Socket::INET->new( PeerAddr => "10.11.12.14",
PeerPort => 234,
Proto => 'tcp',
Timeout => 1);
print "Can't connect to host2: $!\n" if (! $socket2);
____________________________________________________________ ____
Krieg' dabei folgende Ausgabe:
Can't connect to host1: Connection timed out
Can't connect to host2: Operation now in progress
Die erste Zeile ist ja OK (IP ist bei mir nicht belegt).
Doch die 2. Zeile wundert mich sehr. Eigentlich sollte da doch auch ein
"Connection timed out" kommen.
Es hilft auch nicht, wenn ich zwischen den beiden connects ein
sleep(5 Stunden) einbaue.
Hat jemand eine Idee ?
Danke ... Gruss ... Markus
Re: kann keine 2 Sockets connecten: "Operation now in progress" (IO::Socket::INET->new)
Markus Wawersich <aaa [at] aaa-aaa-aaa.de> writes:
>Krieg' dabei folgende Ausgabe:
> Can't connect to host1: Connection timed out
> Can't connect to host2: Operation now in progress
Das ist ein Bug in IO::Socket.
Setz mal an den Anfang des Programms:
use IO::Select;
damit kommt hier (perl-5.8.7) bei den connects jeweils EINPROGRESS,
weil dieser Fehlercode von connect() nicht mehr durch das Laden
von IO::Select zur Laufzeit ueberschrieben wird.
--
--
Michael van Elst
Internet: mlelstv [at] serpens.de
"A potential Snark may lurk in every tree."
Re: kann keine 2 Sockets connecten: "Operation now in progress" (IO::Socket::INET->new)
> Setz mal an den Anfang des Programms:
>
> use IO::Select;
>
> damit kommt hier (perl-5.8.7) bei den connects jeweils EINPROGRESS,
> weil dieser Fehlercode von connect() nicht mehr durch das Laden
> von IO::Select zur Laufzeit ueberschrieben wird.
Danke.
Jetzt geht's.
Gruss ... Markus.
Re: kann keine 2 Sockets connecten: "Operation now in progress" (IO::Socket::INET->new)
mlelstv [at] serpens.de (Michael van Elst) writes:
> Markus Wawersich <aaa [at] aaa-aaa-aaa.de> writes:
>
> >Krieg' dabei folgende Ausgabe:
>
> > Can't connect to host1: Connection timed out
> > Can't connect to host2: Operation now in progress
>
> Das ist ein Bug in IO::Socket.
>
> Setz mal an den Anfang des Programms:
>
> use IO::Select;
>
> damit kommt hier (perl-5.8.7) bei den connects jeweils EINPROGRESS,
> weil dieser Fehlercode von connect() nicht mehr durch das Laden
> von IO::Select zur Laufzeit ueberschrieben wird.
>
Korrekt. Es sieht so aus, als ob folgender Patch (hier gegen
bleedperl, gegen maintperl sollte ähnlich sein) das Problem behebt.
--- bleedperl/lib/IO/Socket.pm Tue Apr 4 12:35:30 2006
+++ bleedperl2/lib/IO/Socket.pm Sun May 21 11:45:44 2006
[at] [at] -115,6 +115,9 [at] [at] sub connect {
if (defined $timeout && ($!{EINPROGRESS} || $!{EWOULDBLOCK})) {
require IO::Select;
+ $err = $!;
+ $! = 0;
+
my $sel = new IO::Select $sock;
if (!$sel->can_write($timeout)) {
--
Slaven Rezic - slaven <at> rezic <dot> de
Tired of using file selectors? Real programmers use the TAB key for
completion and not for jumping around. Try
http://search.cpan.org/search?mode=module&query=Tk::PathEntr y