Determine socket family at runtime

Wojciech Walczak wojtek.gminick.walczak at gmail.com
Sun May 4 12:34:04 EDT 2008


2008/5/4, Giampaolo Rodola' <gnewsg at gmail.com>:
>  For now I've been able to determine the family by using:
>
>  # self.socket = a connected socket.socket instance
>  ip, port = self.socket.getsockname()[0:2]
>  af = socket.getaddrinfo(ip, port)[0][0]
>
>  ...but I'd like to know if some other solution is preferable.

Nope, there is none. Using getaddrinfo() to check address family
is the de facto standard.

-- 
Regards,
Wojtek Walczak
http://www.stud.umk.pl/~wojtekwa/



More information about the Python-list mailing list