Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get address family from socket. Linux

I want to write a C++ wrapper for the Linux Socket API. In the socket() ctor the adress family (AF) is requested. I dont want to require the AF in the connect() signature again, becuase it has been already given in the constructor of socket. So how do I get the AF from an existing socket?

like image 944
ManuelSchneid3r Avatar asked Dec 12 '22 20:12

ManuelSchneid3r


1 Answers

Damn. Searched about half an hour. Now after posting this question I found immiediately the answer.

getsockopt([...]) with option SO_DOMAIN (see socket options)

like image 65
ManuelSchneid3r Avatar answered Dec 22 '22 23:12

ManuelSchneid3r