In order to resolve host names, netlib uses the standard dns lookup mechanism. net_FindAddress() makes the gethostbyname call to lookup the ip address for the specified host, and is called from NET_BeginConnect(). If a numeric ip address is passed into net_FindAddress(), it is passed directly into the getHostByName call which will always return success when an ip address is passed in. If a successful lookup is made, the result is cached in the netlib dns cache (a simple XP_List struct) for a default time of 900 seconds (15 minutes). The dns cache expiration time is user configurable via the prefs.js file, simply add/edit this line:
user_pref("network.dnsCacheExpiration", 900);
Dns lookup behavior can be asynchronous or not, depending on whether or not a front end specific async dns lookup routine is provided. If an async routine is provided, the host name is passed into it along with a host entity structure. The first call to the async routine returns the "waiting for lookup" value immediately so execution is not blocked, and the next_state variable for that connection is updated to "NET_TCP_FINISH_DNS_LOOKUP" so netlib knows to call net_FindAddress() again to get the result of the lookup. net_FindAddress() is actually called repeatedly until it returns success or failure. Upon success the host entity struct is filled out, and cached. Upon failure, the host entity struct is freed and the "not found" result is passed back up to the caller.
If no async routine is provided, net_FindAddress() makes a direct, blocking call to PR_GetHostByName(). If this call returns success, the host entity is cached, otherwise memory is free'd and the "not found" result is passed back up to the caller.
Netlib used to select an ip address from a particular host's entity structure at random, however, since dns servers themselves have started to employ load balancing algorithms to determine in what order to return the ip address.
Judson Valeski, 1998