Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
Open C Sockets: getsockopt, setsockopt method
The getsockopt, setsockopt methods gets and sets options on sockets.
int getsockopt (int s, int level, int optname, void * restrict optval,
socklen_t * restrict optlen);
int setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
The getsockopt and setsockopt system calls manipulate the options associated with a socket. Options may exist at multiple protocol levels; they are always present at the uppermost "socket" level.
Following is the usage of getsockopt and setsockopt system calls:
int optval = 1;
unsigned int optlen = sizeof(optval);
sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);