Linux::Perl::sendmsg
my $bytes = Linux::Perl::sendmsg->sendmsg( fd => $fd, name => $name, iovec => [ \$str1, \$str2, .. ], control => [ $level, $type, $data ], flags => \@flags, );
You can alternatively use your platform-specific module, e.g., Linux::Perl::sendmsg::x86_64.
This module provides a Linux-specific sendmsg() implementation. See man 2 sendmsg for what this can do differently from send() and sendto.
sendmsg()
man 2 sendmsg
send()
sendto
If EAGAIN/EWOULDBLOCK is encountered, undef is returned.
%OPTS correspond to the system call arguments:
fd
name - irrelevant for connected sockets
name
iovec - Optional, a reference to an array of string references
iovec
control - Optional, a reference to an array of: $LEVEL, $TYPE, $DATA. See below for examples. If you don’t use this, you might as well use Perl’s send() built-in.
control
flags - Optional, a reference to an array of any/all of: CONFIRM, DONTROUTE, DONTWAIT, EOR, MORE, NOSIGNAL, OOB.
flags
CONFIRM
DONTROUTE
DONTWAIT
EOR
MORE
NOSIGNAL
OOB
use Socket; control => [ Socket::SOL_SOCKET(), Socket::SCM_CREDENTIALS(), pack( 'I!*', $$, $>, split( m< >, $) ) ), ]
control => [ Socket::SOL_SOCKET(), Socket::SCM_RIGHTS(), pack( 'I!*', @file_descriptors ), ]
Also see Socket::MsgHdr’s documentation for another example.
I’m not sure if recvmsg() is feasible to implement in pure Perl, but that would be a natural complement to this module.
recvmsg()
Socket::MsgHdr provides both sendmsg() and recvmsg().
To install Linux::Perl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Linux::Perl
CPAN shell
perl -MCPAN -e shell install Linux::Perl
For more information on module installation, please visit the detailed CPAN module installation guide.