A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Perl/perl5/issues/20920 below:

POSIX::dup2() creates an invalid socket on Windows · Issue #20920 · Perl/perl5 · GitHub

Module: POSIX

Description
I thought this was already reported, but apparently not. This happens on all Windows versions and all compilers/CRTs.

Steps to Reproduce
Taken from an IO::Socket::IP ticket:

use warnings;
use strict;
  
use POSIX 'dup2';
use Socket;
  
my ($testHost,$testPort)=('perl.org',443);
my $tcpProto=getprotobyname('tcp');
  
socket(my $sock, PF_INET6, SOCK_STREAM, $tcpProto)
  or die "Could not create IPv6 socket - $!\n";
socket(my $sock2, PF_INET, SOCK_STREAM, $tcpProto)
  or die "Could not create IPv4 socket - $!\n";
  
dup2($sock2->fileno,$sock->fileno)
  or die "Unable to dup2 IPv4 socket onto IPv6 socket - $!\n";
  
my $iaddr=inet_aton($testHost);
my $paddr=sockaddr_in($testPort,$iaddr);
connect($sock,$paddr)
  or die "Failed to connect to $testHost:$testPort - $!\n";
  
print "Successfully connected to $testHost:$testPort\n";

Expected behavior
It should connect successfully.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4