问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/11940341/programmatically-finding-ip-address-of-another-computer-on-lan