Kundan Kumar
Kundan Kumar

Reputation: 2002

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 family?

Upvotes: 0

Views: 86

Answers (2)

Andrey
Andrey

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

n. m. could be an AI
n. m. could be an AI

Reputation: 119857

You can call getsockname, but only after the socket is bound.

Upvotes: 2

Related Questions