[Pythonmac-SIG] Mac OS X native DNS lookups
James Mills
prologic at shortcircuit.net.au
Wed Nov 3 03:16:34 CET 2010
On Wed, Nov 3, 2010 at 11:47 AM, Nicholas Riley <njriley at illinois.edu> wrote:
> Try socket.gethostbyname for IPv4-only or socket.getaddrinfo for
> IPv4/IPv6. For example:
>
>>>> import socket
>>>> socket.gethostbyname('mary.local')
> '192.168.71.1'
>>>> socket.getaddrinfo('bookworm.griley.members.mac.com', None, socket.AF_INET6, socket.SOCK_STREAM)
> [(30, 1, 6, '', ('fda1:5f1b:430f:37cc:214:51ff:fe0b:d94', 0, 0, 0))]
The problem with this (that we have) is that when/if the dns servers change
(example: unplug the wire, turn on the wireless) this method of resolving names
isn't able to tell that the dns servers have changed quickly enough.
On Windows we've solved this by hooking into win32 calls (windns I believe)
and using ctypes.
We're after something similar on the Mac OS X platform ideally...
cheers
James
--
-- James Mills
--
-- "Problems are solved by method"
More information about the Pythonmac-SIG
mailing list