setsockopt (sys/socket.h)

Posted by lojin on Stack Overflow See other posts from Stack Overflow or by lojin
Published on 2010-04-02T13:41:48Z Indexed on 2010/04/02 13:43 UTC
Read the original article Hit count: 219

Filed under:
|
|
|

The prototype for setsockopt is:

int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len);

Are the following all correct ? Which are not ?

a.) int buffsize = 50000; setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&buffsize, sizeof(buffsize));

b.) int buffsize = 50000; setsockopt(s, SOL_SOCKET, SO_RCVBUF, (void *)&buffsize, sizeof(buffsize));

c.) char *buffsize = "50000"; setsockopt(s, SOL_SOCKET, SO_RCVBUF, buffsize, strlen(buffsize));

d.) setsockopt(s, SOL_SOCKET, SO_RCVBUF, "50000", 5);

© Stack Overflow or respective owner

Related posts about c

    Related posts about socket