setsockopt SOCKET
, LEVEL
, OPTNAME
, OPTVAL
This function sets the socket option requested.
The function returns undefined if there is an error. OPTVAL
may be
specified as undef if you don't want to pass an argument.
A common option to set on a socket is SO_REUSEADDR
,
to get around the problem
of not being able to bind to a particular address while the previous TCP
connection on that port is still making up its mind to shut down. That
would look like this:
use Socket;
...
setsockopt(MYSOCK
, SOL_SOCKET, SO_REUSEADDR, 1)
or warn "Can't do setsockopt: $!\n";