From 19bfc3babed25a0a7e862cfa8b02d82fe9ebe6e4 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Thu, 24 May 2018 08:53:41 +0000 Subject: [PATCH] HttpUtils.pm: add some comments git-svn-id: https://svn.fhem.de/fhem/trunk@16768 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/HttpUtils.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/HttpUtils.pm b/fhem/FHEM/HttpUtils.pm index df0b9b92e..057e4d23f 100644 --- a/fhem/FHEM/HttpUtils.pm +++ b/fhem/FHEM/HttpUtils.pm @@ -189,15 +189,15 @@ HttpUtils_gethostbyname($$$$) if(!$dnsServer) { # use the blocking libc to get the IP if($haveInet6) { - $host = $1 if($host =~ m/^\[([a-f0-9:]+)\]+$/); - my $iaddr = Socket6::inet_pton(AF_INET6, $host); + $host = $1 if($host =~ m/^\[([a-f0-9:]+)\]+$/); # remove [] from IPV6 + my $iaddr = Socket6::inet_pton(AF_INET6, $host); # Try it as IPV6 return $fn->($hash, undef, $iaddr) if($iaddr); - $iaddr = Socket6::inet_pton(AF_INET , $host); + $iaddr = Socket6::inet_pton(AF_INET , $host); # Try it as IPV4 return $fn->($hash, undef, $iaddr) if($iaddr); my ($s4, $s6); - my @res = Socket6::getaddrinfo($host, 80); + my @res = Socket6::getaddrinfo($host, 80); # gethostbyname, blocks for(my $i=0; $i+5<=@res; $i+=5) { $s4 = $res[$i+3] if($res[$i] == AF_INET && !$s4); $s6 = $res[$i+3] if($res[$i] == AF_INET6 && !$s6); @@ -389,11 +389,12 @@ HttpUtils_Connect($) Socket6::pack_sockaddr_in6($port, $iaddr); my $ret = connect($hash->{conn}, $sa); if(!$ret) { - if($!{EINPROGRESS} || int($!)==10035 || + if($!{EINPROGRESS} || + int($!)==10035 || # WSAEWOULDBLOCK (int($!)==140 && $^O eq "MSWin32")) { # Nonblocking connect $hash->{FD} = $hash->{conn}->fileno(); - my %timerHash=(hash=>$hash,sts=>$selectTimestamp,msg=>"connect to"); + my %timerHash = (hash=>$hash,sts=>$selectTimestamp,msg=>"connect to"); $hash->{directWriteFn} = sub() { delete($hash->{FD}); delete($hash->{directWriteFn});