Subject: sethostent(1): is it really that useful with a DNS?
To: None <tech-userlevel@netbsd.org>
From: Chuck Cranor <chuck@research.att.com>
List: tech-userlevel
Date: 06/11/2001 11:07:26
here is something that is annoying: every time you run netstat
it makes a TCP connection to your DNS resolver.   this is due to
the sethostent(1) call in main.c.   this leads to the following
annoying effect:


xxxcdc> netstat -f inet
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        State
tcp        0      0  xxxcdc.research..64091 chips.research.a.telne ESTABLISHED
xxxcdc> netstat -f inet
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        State
tcp        0      0  xxxcdc.research..64090 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64091 chips.research.a.telne ESTABLISHED
xxxcdc> netstat -f inet
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        State
tcp        0      0  xxxcdc.research..64089 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64090 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64091 chips.research.a.telne ESTABLISHED
xxxcdc> netstat -f inet
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        State
tcp        0      0  xxxcdc.research..64088 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64089 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64090 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64091 chips.research.a.telne ESTABLISHED
xxxcdc> netstat -f inet
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        State
tcp        0      0  xxxcdc.research..64087 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64088 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64089 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64090 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64091 chips.research.a.telne ESTABLISHED
xxxcdc> netstat -f inet
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        State
tcp        0      0  xxxcdc.research..64086 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64087 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64088 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64089 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64090 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64091 chips.research.a.telne ESTABLISHED
xxxcdc> netstat -f inet
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        State
tcp        0      0  xxxcdc.research..64085 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64086 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64087 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64088 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64089 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64090 malmsey.research.domai TIME_WAIT
tcp        0      0  xxxcdc.research..64091 chips.research.a.telne ESTABLISHED
xxxcdc> 




what is this sethostent(1) really buying us?    the man page says:

     The sethostent() function may be used to request the use of a connected
     TCP socket for queries.  If the stayopen flag is non-zero, this sets the
     option to send all queries to the name server using TCP and to retain the
     connection after each call to gethostbyname(), gethostbyname2() or
     gethostbyaddr().  Otherwise, queries are performed using UDP datagrams.


chuck