Knowing the family with Socket Descriptor
I have the socket descriptor which is the return value of socket API. How can I use only this to know the fa开发者_如何学编程mily?
You can call getsockname
, but only after the socket is bound.
(Windows-specific): you can get SO_PROTOCOL_INFO socket option.
If successful, it would give you WSAPROTOCOL_INFO structure with iAddressFamily
member.
精彩评论