[英]Resolve a hostname to ip address from host file C
I am working on grid cluster interconnected. 我正在互连网格集群。 all the host to ip address mapping are in the /etc/host file.
所有主机到ip地址的映射都在/ etc / host文件中。 my question is how can i get the ip by the hostname in my C code.
我的问题是如何在我的C代码中按主机名获取IP。 I can directly ssh compute-0-4.local .
我可以直接ssh compute-0-4.local。 but how can i get its ip in my C code?
但是如何在我的C代码中获取其ip?
使用getaddrinfo()
函数进行名称查找。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.