Now you can find all of the software that used a regex on [.0-9]+ to decide if you gave them an IP or a name.
I would never have done that… on any software that is still in service, to my knowledge.
Edit: The right way is not to try to determine which it is, pass it to inet_pton() on the assumption that it is a numeric address. If that fails, then pass it in to getaddrinfo() to let DNS or whatever the host uses for names have a crack at it. gethostbyname is obsolete now.
I would never have done that… on any software that is still in service, to my knowledge.
Edit: The right way is not to try to determine which it is, pass it to inet_pton() on the assumption that it is a numeric address. If that fails, then pass it in to getaddrinfo() to let DNS or whatever the host uses for names have a crack at it. gethostbyname is obsolete now.