Reputation: 2002
I have the socket descriptor which is the return value of socket API. How can I use only this to know the family?
Upvotes: 0
Views: 86
Reputation: 4356
(Windows-specific): you can get SO_PROTOCOL_INFO socket option.
If successful, it would give you WSAPROTOCOL_INFO structure with iAddressFamily
member.
Upvotes: 1
Reputation: 119857
You can call getsockname
, but only after the socket is bound.
Upvotes: 2