Recently, I'm working on development of the network application which is base on Linux platform(2.6.32). My scenario is that the device need to send data to server periodically. Every time the network code calls the function getaddinfo() firstly, it would return the server IP address, and then I passed this value to socket interface or libcurl api.
However, I found that if the /etc/resolv.conf was set to a invalid value, such as nameserver 169.254.1.1, the getaddrinfo() will return a error value(-3). Even I update the /etc/resolv.conf to a valid value, the getaddrinfo() still return the error.
It seems that getaddrinfo() function won't update the nameserver value after the first time call.
My solution is to call the getaddrinfo() in a independent process(not thread). I found it's a feasible way to resolve the above issue.
What is the root cause of the above issue?