File: listen_port_only.t

package info (click to toggle)
libio-socket-inet6-perl 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 184 kB
  • ctags: 25
  • sloc: perl: 994; makefile: 5
file content (42 lines) | stat: -rw-r--r-- 762 bytes parent folder | download | duplicates (6)
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
35
36
37
38
39
40
41
42
#!/usr/bin/perl

use strict;
use warnings;
use IO::Socket::INET6;

use Test::More;

my ($server,$port);
# try to create inet6 listener on some port, w/o given
# LocalHost (should use :: then)
CREATE_SERVER:
for my $i (1 .. 100)
{
    $port = int(rand(50000)+2000);
    $server = IO::Socket::INET6->new(
        LocalPort => $port,
        Listen => 10,
    );
    if ($server)
    {
        last CREATE_SERVER;
    }
}

if (!$server)
{
    plan skip_all => "failed to create inet6 listener";
}
elsif ( $server->sockhost ne '::' )
{
    plan skip_all => "not listening on ::, maybe inet6 not available";
}
else
{
    plan tests => 1;

    my $client = IO::Socket::INET6->new( "[::1]:$port" );

    # TEST
    ok($client, "Client was initialised - connected.");
}