mirror of https://github.com/BOINC/boinc.git
get local IP addr fix
svn path=/trunk/boinc/; revision=695
This commit is contained in:
parent
fb088f6034
commit
cb6a0554b1
|
@ -2557,3 +2557,7 @@ David Dec 5 2002
|
|||
tools/
|
||||
backend_lib.C,h
|
||||
create_work.C
|
||||
|
||||
David Dec 6 2002
|
||||
- fix bugs in get_local_ip_addr()
|
||||
(need to figure out why they were happening)
|
||||
|
|
|
@ -170,10 +170,15 @@ int get_local_ip_addr_str(char* p) {
|
|||
#if HAVE_NETDB_H || _WIN32
|
||||
char buf[256];
|
||||
struct in_addr addr;
|
||||
if (gethostname(buf, 256))
|
||||
if (gethostname(buf, 256)) {
|
||||
printf("gethostname() didn't return name\n");
|
||||
return -1;
|
||||
}
|
||||
struct hostent* he = gethostbyname(buf);
|
||||
if (!he) return -1;
|
||||
if (!he || !he->h_addr_list[0]) {
|
||||
printf("gethostbyname() didn't return any IP addresses\n");
|
||||
return -1;
|
||||
}
|
||||
memcpy(&addr, he->h_addr_list[0], sizeof(addr));
|
||||
strcpy(p, inet_ntoa(addr));
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue