Discussion:
Computer name from IP
(too old to reply)
Richard Bibby
2008-07-19 13:46:12 UTC
Permalink
Hej,

If I know the IP number of a computer in my local network can I look up its
name?

And given a name can I look up its IP?

Many thanks!

/Richard
Jamie Dale
2008-07-19 15:32:31 UTC
Permalink
Yes it can be done (both).

There are a few methods of doing it - I found 2 a while back but they're not
always successful (EG it will return wrong mac address etc)

Give me a few hours and I'll try to post source..
Post by Richard Bibby
Hej,
If I know the IP number of a computer in my local network can I look up
its name?
And given a name can I look up its IP?
Many thanks!
/Richard
Raul
2008-07-19 16:13:06 UTC
Permalink
Couple of sample delphi sources (untested) :

Host to Ip : http://www.delphi3000.com/articles/article_1697.asp?SK=

IP to host : http://www.delphi3000.com/articles/article_1664.asp?SK=

If you have DNS resolution capability in your network then you can also use
any DNS component out there (assuming both forward and reverse lookup
records exist).


Raul
Post by Richard Bibby
Hej,
If I know the IP number of a computer in my local network can I look up
its name?
And given a name can I look up its IP?
Many thanks!
/Richard
Jamie Dale
2008-07-19 21:25:34 UTC
Permalink
Post by Raul
Host to Ip : http://www.delphi3000.com/articles/article_1697.asp?SK=
IP to host : http://www.delphi3000.com/articles/article_1664.asp?SK=
@Richard, do you still want me to provide source code that I found? (Sorry I
couldn't earlier its been a busy day)
Remy Lebeau (TeamB)
2008-07-20 07:22:06 UTC
Permalink
Post by Richard Bibby
If I know the IP number of a computer in my local network
can I look up its name?
Look at the winsock gethostbyaddr() function.
Post by Richard Bibby
And given a name can I look up its IP?
gethostbyname()


Gambit

Loading...