Path: csiph.com!usenet.pasdenom.info!news.albasani.net!news.mixmin.net!news.linkpendium.com!news.linkpendium.com!panix!panix2.panix.com!not-for-mail From: roy@panix.com (Roy Smith) Newsgroups: comp.lang.python Subject: Re: Subprocess puzzle and two questions Date: 14 Nov 2012 11:20:54 -0500 Organization: PANIX -- Public Access Networks Corp. Lines: 25 Message-ID: References: NNTP-Posting-Host: panix2.panix.com X-Trace: reader1.panix.com 1352910054 9808 166.84.1.2 (14 Nov 2012 16:20:54 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Wed, 14 Nov 2012 16:20:54 +0000 (UTC) Xref: csiph.com comp.lang.python:33346 I 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... >> >> s = socket.socket() >> s.connect(('8.8.8.8', 53)) In article , Chris Angelico wrote: >That assumes that (a) the remote server supports TCP for DNS This is true. I honestly don't know what percentage of DNS servers out there only support UDP. The two I tried (Google's 8.8.8.8, and my Apple TimeCapsule) both supported TCP, but that's hardly a representitive sample. > and (b) that connection time for TCP is comparable to > ping or an actual DNS lookup. My first thought to solve both of these is that it shouldn't be too hard to hand-craft a minimal DNS query and send it over UDP. Then, I hunted around a bit and found that somebody had already done that, in spades. Take a look at http://www.dnspython.org; it might be exactly what's needed here.