[Python-Dev] Re: More socket questions
Marangozov, Vladimir (Vladimir)
Fri, 11 Apr 2003 04:38:12 -0400
inet_aton() is a pretty simple parser of an IP address string,
but it is not available on all setups. Libraries relying on
it usually provide a local version. So do the same.
Search the Web for "inet_aton.c" and you'll hit a standard
implementation, with all the niceties about the base encoding
of each part of the IP address which follows the C convention:
0x - hex, 0 - octal, other - decimal. And thus, BTW,
"ping 22.214.171.124" is not the same as "ping 192.030.020.010".
So take that code, stuff it in my_inet_aton() and case closed.
You could use my_inet_aton() before calling gethostbyname('name')
to see whether 'name' is an IP address and return immediately,
but as I said, decent resolvers should do that for you. After
all, their job is to give you an IP address in return. If you
feed an IP address as an input, you should get it as a reply.
Not all resolvers are decent, though. On top of that, some have
bugs :-). I can't answer the question about netdb's status quo.