Search code examples
objective-cip-addresslan

Programmatically finding IP address of another computer on LAN


I want to programmatically obtain the IP address of a computer on the LAN, given its hostname.

I know from the command line i can do this by ping < hostname >, but how can i do this programmatically in objective-c? Thanks.


Solution

  • Ok, gethostbyname() always works when trying to find the ip address given a hostname, as long as the hostname of the computer you ae trying to access has its name registered in a DNS Server. All comments and answers above were useful.