Forum Moderators: coopster

Message Too Old, No Replies

What makes gethostbyaddr fail?

         

otem

10:30 pm on Feb 13, 2007 (gmt 0)

10+ Year Member



I'm starting to get familiar with the gethostbyaddr function, and notice that sometimes it returns the exact ip address that I'm trying to get the host by.

I read on PHP's website that gethostbyaddr "returns the host name of the Internet host specified by ip_address or a string containing the unmodified ip_address on failure."

However, I'm curious. What makes gethostbyaddr fail, and is there anything I can do to help it not fail, or is there a related function that might work if it does?

Thanks.

eelixduppy

11:25 pm on Feb 13, 2007 (gmt 0)



I suppose what would make it fail is if the address is not properly formatted or if it doesn't exist. The former can be checked using string functions, but you won't know about the latter until you use the function.

otem

11:45 pm on Feb 13, 2007 (gmt 0)

10+ Year Member



Thanks for the reply.

I'm trying to grab the host of my visitors based of their ip addresses.

Some are working, but some are just returning their ip addresses. Surely this wouldn't suggest these users are using fake ip addresses? Would it?

eelixduppy

11:54 pm on Feb 13, 2007 (gmt 0)




Surely this wouldn't suggest these users are using fake ip addresses? Would it?

It's not so much that they don't exist but rather that a record cannot be found for it.