Knowing that the
size of the sending and receiving buffers for the default socket are quite
large, you as an application designer might decide that a smaller set of
buffers might be more appropriate. This might be
especially significant if you are expecting several instances of the program to run on your system.
Options are set
on sockets using the setsockopt(2) function. Its function prototype is given as
follows:
#include
<sys/types.h>
#include
<sys/socket.h>
int
setsockopt(int s,
int level,
int optname,
const void *optval,
socklen_t optlen);
This function
closely resembles the getsockopt(2) function discussed earlier. The arguments for
setsockopt(2) are listed as follows:
- The socket s to effect an option change upon.
- The socket level of the option.
- The option optname to set.
- The pointer optval to the value to be used for the new option value.
- The option value length optlen, in bytes.
The only real
difference between this function's arguments and the getsockopt(2) argument
list is that the last argument is passed by value only. It is an input value
only in this case.
No comments:
Post a Comment