Q:
A program that I need to run will not work. When I try to run it, I get the following error:
*** Cannot identify 'squinnux' IP address. gethostbyname() returns localhost.
My /etc/hosts file is set to:
127.0.0.1 squinnux localhost.localdomain localhost
what can I do to get around this error?
Thanks!
A:
First, squinnex should not be in that line. You should have a seperate line with your actual IP address and host name.
Code:127.0.0.1 localhost.localdomain localhost
192.168.0.1 squinnex
Then /etc/sysconfig/network should have the following lines:192.168.0.1 squinnex
NETWORKING=yes
HOSTNAME=squinnex
直接设置网络地址为INADDR_ANY。有的服务器是多宿主机可能有多个网卡,那么运行在这样的服务器上的服务程序在为其Socket绑定IP地址时可以把htonl(INADDR_ANY)置 给s_addr,这样做的好处是不论哪个网段上的客户程序都能与该服务程序通信;如果只给运行在多宿主机上的服务程序的Socket绑定一个固定的IP地 址,那么就只有与该IP地址处于同一个网段上的客户程序才能与该服务程序通信。