Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'socket': 0.05; 'subject:two': 0.07; 'oh,': 0.09; 'ping': 0.09; 'times,': 0.13; 'enough.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'processes.': 0.16; 'roy': 0.16; 'subject:questions': 0.16; 'tcp': 0.16; 'time.time()': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'import': 0.21; '(b)': 0.22; 'assumes': 0.22; '15,': 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'used,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'actual': 0.28; '(since': 0.29; 'case,': 0.29; 'connection': 0.30; 'seconds': 0.30; 'print': 0.32; '(a)': 0.33; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'server': 0.35; 'nov': 0.35; 'remote': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'but': 0.36; 'supporting': 0.37; 'received:209': 0.37; 'far': 0.37; 'subject:: ': 0.38; 'supports': 0.38; 'some': 0.38; 'several': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'more': 0.63; 'smith': 0.71; 'comparable': 0.84; '"it': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=BRwfDtOtpODUDzV3ASwWIA++1IO0oapUHmrkZg5Gt28=; b=NAXk2Uv0EbFTzyMGXQmiY6FEFlna9LL18nSzyqfefMDO5GNKTgDMnXTsrhzaU81x/T tREPX9U6cWXlL908mBw+6W+0zgmmPOODOvLlTxWEu9fGwtHYsD3GuwTliI/SKSneg1iu pJHsBYo8KfZYPyQ2n1nsjoOUbt9YEMfpMpcU3JG4nUuUAod/OAopBe2UxgOiZgucs+xO ncU1ooAgu1qdu7av1XBs8TBYHplZ4l0g9wc1ZLTdasWaQOPivMUeEzL4sQr8+fZDBlga TIiVe8q8XMRISRmBrb+LoTF/wJh0dt6yk0VvS4xCXA8dM+6axAzSxA149PUY1kWACUp5 KhgQ== MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 15 Nov 2012 01:40:05 +1100 Subject: Re: Subprocess puzzle and two questions From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352904008 news.xs4all.nl 6892 [2001:888:2000:d::a6]:60310 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33338 On Thu, Nov 15, 2012 at 1:22 AM, Roy Smith 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