On Thu, Nov 15, 2012 at 1:22 AM, Roy Smith <r...@panix.com> wrote: > Oh, my. You're using DNS as a replacement for ping? Fair enough. In > that case, all you really care about is that you can connect to port 53 > on the server... > > import socket > import time > s = socket.socket() > t0 = time.time() > s.connect(('8.8.8.8', 53)) > t1 = time.time() > print "it took %f seconds to connect" % (t1 - t0)
That assumes that (a) the remote server supports TCP for DNS (since UDP is by far the more often used, some name servers don't bother supporting TCP), and (b) that connection time for TCP is comparable to ping or an actual DNS lookup. But in terms of approximating your connection times, that's gotta be way better than shelling out to several other processes. ChrisA -- http://mail.python.org/mailman/listinfo/python-list