start page | rating of books | rating of authors | reviews | copyrights

Programming Perl

Programming PerlSearch this book
Previous: 3.2.141 setpriority Chapter 3
Functions
Next: 3.2.143 shift
 

3.2.142 setsockopt

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";


Previous: 3.2.141 setpriority Programming Perl Next: 3.2.143 shift
3.2.141 setpriority Book Index 3.2.143 shift