Socket timeout not working with libUrl

Alex Tweedly alex at
Mon Jan 31 21:09:12 EST 2005

Sarah Reichelt wrote:

>>    2) If I open the socket with a domain address, e.g. 
>>, Mac OS X does a DNS lookup, puts up the rainbow 
>> rotating color cursor, and hangs until the DNS lookup fails.  On my 
>> machine this takes 60 seconds (apparently it's dependent on how many 
>> dns servers you have listed).
> What happens if you try:
>   hostNameToAddress("")
> and use the result of that as the address for opening the socket?
> In my tests, this takes about 4 seconds the first time it is called if 
> I am connected (which is long enough for the SPOD to appear). When I 
> am disconnected, it fails instantly and return empty.

It depends how you are connected.

If you do it on a machine directly connected to the Internet (e.g. my 
laptop dialled into my ISP), then it will fail immediately (because it 
knows the DNS server (obtained in this case by PPP negotiation)  is 

If you do this on a host which is connected to a LAN and (has been) 
using a router attached to the LAN to connect, and the router (and/or 
NAT box) has been configured (e.g. through DHCP) as the DNS server for 
the host, and the router has lost its Internet connection, THEN it will 
block for 15-120 seconds before failing. (example - my laptop, connected 
through another PG running Win Internet Connection Sharing to a dial-up 
{Note - if you're testing this, remember the address will be kept in the 
router's DNS resolver cache, so after any successful attempt, you need 
to either wait or change the host name you are looking up - that just 
caught me out when I tried this in preparation to send this email :-].

No doubt there are other circumstances where it would similarly fail 
(e.g. maybe the case of a router hop between the host and the DNS 
router/server, and the router-to-router link was down - but I haven't 
test that one yet; it would depend on whether the intermediate router 
was proxying DHCP or sub-leasing - and I suspect there are too many 
variants to be worth getting into them).

The engine can't return a response to the hostnametoaddress query until 
it gets a response from the DNS server (or the query times out), so it 
simply blocks until the time-out. That's probably reasonable (or at 
least unavoidable) for a blocking call like hostNameToAddress, but there 
needs to be a non-blocking version of it, for use in non-blocking libURL 
and any other action which is not user-triggered (or even to make the 

-- Alex.

No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.6 - Release Date: 27/01/2005

More information about the Use-livecode mailing list