get local IP addr fix

svn path=/trunk/boinc/; revision=695
This commit is contained in:
David Anderson 2002-12-06 08:37:21 +00:00
parent fb088f6034
commit cb6a0554b1
3 changed files with 13 additions and 2 deletions

View File

@ -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)

View File

@ -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

2
todo
View File

@ -1,3 +1,5 @@
support for HTTP and SOCKS proxies
make get_local_ip_addr() work in all cases
est_time_to_completion doesn't work for non-running tasks
get timezone working on all platforms
get benchmark working as separate process