Blake
Blake

Reputation: 7547

optlen parameter in getsockopt()

I went through the documentation, but still didn't get what does optlen do in getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) , can anyone explain?

Upvotes: 2

Views: 619

Answers (2)

demo.b
demo.b

Reputation: 3449

Optlen is an in-out parameter used to specify the length of the buffer.

Upvotes: 1

user207421
user207421

Reputation: 311054

You set it to the size of the data item you're receiving the option value into. On return the size may have been adjusted.

The documentation does say that.

Upvotes: 3

Related Questions