in reply to Re: Getting IPv6 with the Cookbook
in thread Getting IPv6 with the Cookbook
Here is the final code I generated:
sub make_server { my ($ipv6,$localHost,$conn,$protocol,$socket_port,$verbose) = @_; my $server; print "Using protocol = $protocol on $localHost with port = $socket +_port.\n" if $verbose; if ($ipv6) { print "Running IPv6 tests.\n" if $verbose; $server = IO::Socket::INET6->new(LocalAddr => "$localHost:$soc +ket_port", Proto => $protocol, Reuse => 1, Listen => $conn) or die "Couldn't make IPv6 server on port $socket_port: $@\n"; print "Running IPv6 enabled on port $socket_port.\n" if $verbos +e; } else { print "Running IPv4 tests.\n" if $verbose; $server = IO::Socket::INET->new(LocalAddr => "$localHost:$sock +et_port", Proto => $protocol, Reuse => 1, Listen => $conn) or die "Can't make $protocol server on port $socket_port: $@\n +"; print "Running on port $socket_port.\n" if $verbose; } return($server); }
A little about this code....it's made to use the $protocol flag to handle some test cases for TCP and UDP, the Server starts up and handles a Client that connects using similar code to start up with the same conditions. What I was trying to handle was not only IPv4 but IPv6, plus conditions for TCP and UDP so I can just send flags to the creation of the Server or Client and have them generate what I need.
Of course none of this addresses the fact that I also need to make something with Named Pipes for Windows, but that's another story.
|
|---|