c - Resolving host name -


i can resolve hostname

getaddrinfo ()

and validate address. can use

connect(socket, sockaddr, len)

i'm not sure connect does. because if try modify hosts file e.g. modify ip-address host name. connect() still works fine.

e.g.

foo.bar 1.1.1.1 ---> foo.bar 2.2.2.2

is there anyway know oh, no more 1.1.1.1 valid, 2.2.2.2

getaddrinfo() translates addrinfo structs containing sockaddr structs can in turn used connect() socket, cares raw ipv4/ipv6/unix domain addresses. connect() needs raw addresses, not know or care @ came (translated, hardcoded 32 bit integers, etc.), , connecting address not verification translated address "right" one, server on requested raw address open on requested port.

it sounds want cache translated addresses, can beneficial, seem expect changed name mappings "pushed" you. linux systems not cache address translations @ os level unless running nscd (name service cache daemon), , there no form of pushing updates applications using dns translation. have re-translate names , see if sockaddr has changed.

if know relevant name/address changes frequent local /etc/hosts modifications (a unlikely scenario, in likelihood!), consider using inotify monitor file updates, flushing local name cache when see change.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -