File: 15io-socket.t

package info (click to toggle)
libio-socket-ip-perl 0.16-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 232 kB
  • sloc: perl: 1,087; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 838 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl -w

use strict;
use Test::More tests => 2;

use IO::Socket;
use IO::Socket::IP -register;

my $sock = IO::Socket->new(
   Domain    => AF_INET,
   Type      => SOCK_STREAM,
   LocalHost => "127.0.0.1",
   LocalPort => 0,
);

isa_ok( $sock, "IO::Socket::IP", 'IO::Socket->new( Domain => AF_INET )' );

SKIP: {
   my $AF_INET6 = eval { Socket::AF_INET6() } ||
                  eval { require Socket6; Socket6::AF_INET6() };
   $AF_INET6 or skip "No AF_INET6", 1;
   eval { IO::Socket::IP->new( LocalHost => "::1" ) } or
      skip "Unable to bind to ::1", 1;

   my $sock = IO::Socket->new(
      Domain    => $AF_INET6,
      Type      => SOCK_STREAM,
      LocalHost => "::1",
      LocalPort => 0,
   );

   isa_ok( $sock, "IO::Socket::IP", 'IO::Socket->new( Domain => AF_INET6 )' ) or
      diag( "  error was $@" );
}