1# test ELOOP for udp splicing loop
2
3use strict;
4use warnings;
5use IO::Socket;
6use BSD::Socket::Splice "SO_SPLICE";
7
8our %args = (
9    errno => 'ELOOP',
10    func => sub {
11	my $s = IO::Socket::INET->new(
12	    Proto => "udp",
13	    LocalAddr => "127.0.0.1",
14	) or die "socket bind failed: $!";
15
16	my $ss = IO::Socket::INET->new(
17	    Proto => "udp",
18	    PeerAddr => $s->sockhost(),
19	    PeerPort => $s->sockport(),
20	) or die "socket connect failed: $!";
21
22	$s->setsockopt(SOL_SOCKET, SO_SPLICE, pack('i', $ss->fileno()))
23	    or die "splice failed: $!";
24
25	defined($ss->send("foo\n"))
26	    or die "socket splice send failed: $!";
27	defined($s->recv(my $buf, 10))
28	    or die "socket recv failed: $!";
29	$buf eq "foo\n"
30	    or die "socket recv unexpected content: $buf";
31	defined($s->recv($buf, 10))
32	    and die "socket recv succeeded";
33    },
34);
35