send

sendSOCKET,MSG,FLAGS,TOsendSOCKET,MSG,FLAGS
This function sends a message on a socket. It takes the same
flags as the syscall of the same name—see send(2).
On unconnected sockets, you must specify a destination to send
TO, which then makes Perl’s send work like sendto(2).
The C syscall sendmsg(2) is currently unimplemented
in standard Perl. The send function
returns the number of characters sent, or undef if there is an error.
Note the characters: depending on the status
of the socket, either (8-bit) bytes or characters are sent. By default,
all sockets operate on bytes. But if, for example, the socket has been
changed using binmode to operate with
the :encoding(utf8) I/O layer, then
its I/O will operate on UTF-8-encoded Unicode characters, not
bytes.
(Some non-Unix systems improperly treat sockets as different from
ordinary file descriptors, with the result that you must always use
send and recv on sockets rather than the handier
standard I/O operators.)
One error that at least one of us makes frequently is to confuse
Perl’s send with C’s send and write:
send SOCK, $buffer, length $buffer; # WRONG
This will mysteriously fail depending on the relationship of the string length ...