You are viewing the version of this documentation from Perl blead. This is the main development branch of Perl. (git commit a7c61e7c6140c01e90759d370b21194631829c1a)
setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL

Sets the socket option requested. Returns undef on error. Use integer constants provided by the Socket module for LEVEL and OPNAME. Values for LEVEL can also be obtained from getprotobyname. OPTVAL might either be a packed string or an integer. An integer OPTVAL is shorthand for pack("i", OPTVAL).

An example disabling Nagle's algorithm on a socket:

use Socket qw(IPPROTO_TCP TCP_NODELAY);
setsockopt($socket, IPPROTO_TCP, TCP_NODELAY, 1);

Portability issues: "setsockopt" in perlport.