C:setsockopt
lastmod 2018-08-17created 2016-12-295 edits
Network environments are complex and varied, and many unpredictable things happen. For this reason, depending on the type of network program, you sometimes need to adjust the details of a socket(:12). Socket details can be adjusted by manipulating socket options, and for this two functions are provided: getsockopt() and setsockopt(). As the names suggest, getsockopt is used to get the current socket option value, and setsockopt is used to change a socket option value.
Syntax
#include <sys/types.h>
#include <sys/socket.h>
int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen);
int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen);
See also
Favorite site
- Joinc - Socket options 1
- Stackoverflow: Maximum buffer length for sendto?
- Mint & Latte_. :: 5. Socket options - setsockopt()
- KLDP - A question about SO_SNDBUF and SO_RCVBUF in socket programming (question about the TCP window and buffers)
References
-
Joinc_-setsockopt-_Socket_option.pdf ↩