[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
gethostbyaddr problem solved!!
the way to use gethostbyaddr. Try:
hi everybody,
binand solved my problem about the
gethostbyaddr system call.
and here it is (if it can help anybody else):-
this is the wrong way to do it:-
hptr=gethostbyaddr("127.0.0.1",4,AF_INET);
this is the right way:-
struct hostent *host;
struct in_addr addr;
inet_aton ("127.0.0.1", &addr);
host = gethostbyaddr ((char *) &addr, sizeof addr,
AF_INET);
if (host == NULL) {
/* Continue */
}
The call to inet_aton is necessary to handle the
endianness
conversions.
ciao
__________________________________________________
Do You Yahoo!?
Yahoo! Photos -- now, 100 FREE prints!
http://photos.yahoo.com