summaryrefslogtreecommitdiff
path: root/regress/sys/kern/splice/error-splice-ENOTSOCK.pl
diff options
context:
space:
mode:
Diffstat (limited to 'regress/sys/kern/splice/error-splice-ENOTSOCK.pl')
-rwxr-xr-xregress/sys/kern/splice/error-splice-ENOTSOCK.pl23
1 files changed, 23 insertions, 0 deletions
diff --git a/regress/sys/kern/splice/error-splice-ENOTSOCK.pl b/regress/sys/kern/splice/error-splice-ENOTSOCK.pl
new file mode 100755
index 00000000000..228536efafb
--- /dev/null
+++ b/regress/sys/kern/splice/error-splice-ENOTSOCK.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+# test ENOTSOCK for splicing with non-socket
+
+use Errno;
+use IO::Socket;
+use constant SO_SPLICE => 0x1023;
+
+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 failed: $!";
+
+$s->setsockopt(SOL_SOCKET, SO_SPLICE, pack('i', 0))
+ and die "splice with non non-socket fileno succeeded";
+$!{ENOTSOCK}
+ or die "error not ENOTSOCK: $!"