I have a test program, I am running on SLES 10 system, that does a gethostbyaddr() for an ip address present in my /etc/hosts file. It returns correct values. After this I made the program wait by having getchar() and in the mean time I modifiy my /etc/hosts file to remove the entry for that ipaddress in /etc/hosts and save the file. After this, I let my program continue and the program does another gethostbyaddr() with the same ipaddress, I expect gethostaddr() to return me error, but instead it is returning correct values. Infact even if I rename /etc/hosts file after it did first gethostbyaddr() the second call returns valid values.

I tested the same program on RH4 and I got expected values.

Could anyone pelase let me know if I need to change any configuration file on SLES10 to make it read afresh each time.

The code is here:
#include <netdb.h>
#include <sys/socket.h>
#include <stdio.h>
#include <strings.h>
extern int h_errno;
struct hostent *he, *he1;
#define addr "192.168.1.10"

int main()
{
struct sockaddr_in serv_addr;
bzero((char *)&serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr(addr);
he = gethostbyaddr( &(serv_addr.sin_addr), sizeof(serv_addr.sin_addr),
AF_INET);
if (he == NULL) {
printf("Error: %s \n", hstrerror(h_errno));
} else {
printf("Host: %s \n", he->h_name);
}
getchar();
he1 = gethostbyaddr( &(serv_addr.sin_addr), sizeof(serv_addr.sin_addr),
AF_INET);
if (he1 == NULL) {
printf("Error: %s \n", hstrerror(h_errno));
} else {
printf("Host: %s \n", he1->h_name);
}
}