blob: c2d108e26fb0b05ab2049b10c36f9c9b54cd39bb (
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
|
# test ELOOP for splicing loop
use strict;
use warnings;
use IO::Socket;
use BSD::Socket::Splice "SO_SPLICE";
our %args = (
errno => 'ELOOP',
func => sub {
my $sl = IO::Socket::INET->new(
Proto => "tcp",
Listen => 5,
LocalAddr => "127.0.0.1",
) or die "socket listen failed: $!";
my $s = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => $sl->sockhost(),
PeerPort => $sl->sockport(),
) or die "socket connect failed: $!";
my $ss = $sl->accept()
or die "socket splice accept failed: $!";
$s->setsockopt(SOL_SOCKET, SO_SPLICE, pack('i', $ss->fileno()))
or die "splice failed: $!";
defined($ss->send("foo\n"))
or die "socket splice send failed: $!";
defined($s->recv(my $buf, 10))
or die "socket recv failed: $!";
$buf eq "foo\n"
or die "socket recv unexpected content: $buf";
defined($s->recv($buf, 10))
and die "socket recv succeeded";
},
);
|