summaryrefslogtreecommitdiff
path: root/dist/IO/t/cachepropagate-tcp.t
blob: 40f36be274714c629608ca9407da5fa150b34ab8 (plain)
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
43
#!/usr/bin/perl

use warnings;
use strict;

use IO::Socket;
use IO::Socket::INET;
use Test;

plan tests => 8;

my $listener = IO::Socket::INET->new(Listen => 1,
                                     LocalAddr => '127.0.0.1',
                                     Proto => 'tcp');
ok(defined($listener));

my $port = $listener->sockport();

my $p = $listener->protocol();
ok(defined($p));
my $d = $listener->sockdomain();
ok(defined($d));
my $s = $listener->socktype();
ok(defined($s));

my $cpid = fork();
ok(defined($cpid));
if (0 == $cpid) {
  # the child:
  sleep(1);
  my $connector = IO::Socket::INET->new(PeerAddr => '127.0.0.1',
                                        PeerPort => $port,
                                        Proto => 'tcp');
  exit(0);
};

my $new = $listener->accept();

ok($new->protocol(), $p);
ok($new->sockdomain(), $d);
ok($new->socktype(), $s);

wait();