I have the socket descriptor which is the return value of socket API. How can I use only this to know the family?
您可以调用getsockname
,但只能在套接字绑定之后。
(Windows-specific): you can get SO_PROTOCOL_INFO socket option.
If successful, it would give you WSAPROTOCOL_INFO structure with iAddressFamily
member.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.