Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18719
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!rt.uk.eu.org!news-transit.tcx.org.uk!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <nicholas.dokos@hp.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'distinct': 0.05; 'returned.': 0.07; '*name*': 0.09; '[0]': 0.09; 'header:In-reply- to:1': 0.09; 'operation,': 0.09; 'subject:error': 0.09; 'am,': 0.12; 'argument': 0.15; '(name,': 0.16; '+short': 0.16; 'instance:': 0.16; 'inverse': 0.16; 'name)': 0.16; 'nick': 0.16; 'rotation': 0.16; 'tuple,': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'jan': 0.19; 'cc:no real name:2**0': 0.20; 'string': 0.24; 'cc:2**0': 0.24; 'module': 0.26; "i'm": 0.26; 'function': 0.27; '(and': 0.28; 'order.': 0.29; 'cc:addr:python.org': 0.29; 'host': 0.30; '(unless': 0.30; 'confused': 0.30; 'chris': 0.30; 'equivalent': 0.31; 'usually': 0.31; 'quite': 0.32; 'list': 0.32; 'tue,': 0.32; 'normally': 0.34; 'dns': 0.34; 'doc': 0.34; 'uses': 0.36; 'element': 0.37; 'but': 0.37; 'list,': 0.37; "there's": 0.37; 'getting': 0.38; 'i.e.': 0.39; 'being': 0.39; 'help': 0.39; "it's": 0.40; 'address': 0.61; 'header:Received:6': 0.61; 'results': 0.63; 'number.': 0.66; '2012': 0.67; 'addresses,': 0.68; 'note:': 0.69; 'reply-to:no real name:2**0': 0.72; 'header:Reply-to:1': 0.84; '(first)': 0.84; 'addresses:': 0.84; 'subject:( ': 0.84; 'canonical': 0.91; 'subject:skip:s 20': 0.91 |
| From | Nick Dokos <nicholas.dokos@hp.com> |
| To | Chris Angelico <rosuav@gmail.com> |
| Subject | Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error |
| In-reply-to | <CAPTjJmp06is_WZv9BRatTvS4Y-=sfGNeL-1k3VZSTQerYYzCVQ@mail.gmail.com> |
| References | <d3865134-491c-45ea-a033-a394e64701db@z19g2000vbe.googlegroups.com> <jdsjld$mau$1@r03.glglgl.gl> <bacea15d-fae0-4b1f-8a8e-a8b06b561fc0@t30g2000vbx.googlegroups.com> <roy-F4BA5C.13424802012012@news.panix.com> <24123dfe-b2fc-4f4c-8dfe-23bfef19b205@m10g2000vbc.googlegroups.com> <roy-4CE54B.15314102012012@news.panix.com> <f683b8f4-3a59-4c9f-94ef-82a9017dcd31@m20g2000vbf.googlegroups.com> <4F0B6BBE.5090501@codeaurora.org> <CAPTjJmp06is_WZv9BRatTvS4Y-=sfGNeL-1k3VZSTQerYYzCVQ@mail.gmail.com> |
| Comments | In-reply-to Chris Angelico <rosuav@gmail.com> message dated "Tue, 10 Jan 2012 10:14:25 +1100." |
| Organization | HPCS |
| X-Mailer | MH-E 8.3.1; nmh 1.3; GNU Emacs 24.0.92 |
| Date | Mon, 09 Jan 2012 18:32:44 -0500 |
| Sender | nicholas.dokos@hp.com |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | nicholas.dokos@hp.com |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4558.1326152352.27778.python-list@python.org> (permalink) |
| Lines | 42 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1326152352 news.xs4all.nl 6957 [2001:888:2000:d::a6]:56883 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:18719 |
Show key headers only | View raw
Chris Angelico <rosuav@gmail.com> wrote: > On Tue, Jan 10, 2012 at 9:35 AM, Dominic Binks <dbinks@codeaurora.org> wrote: > > The address database can have multiple names for the same IP address so > > gethostbyaddr returns a list - [0] being the first item in the list (and > > usually considered the canonical name) > > Point to note: The inverse operation, getting IP addresses from names, > quite frequently returns multiple results - and in that case, there's > no "canonical name". You'll still usually want to take the zeroth > (first) item in the list, but often the list will change in order. > Try, for instance: > > $ dig +short www.google.com > > which uses DNS rotation as a form of load-balancing. > > In any case, you normally just take the first entry. > On both 2.6.6 and 2.7.1, the doc says: ,---- | >>> help(socket.gethostbyaddr) | Help on built-in function gethostbyaddr in module _socket: | | gethostbyaddr(...) | gethostbyaddr(host) -> (name, aliaslist, addresslist) | | Return the true host name, a list of aliases, and a list of IP addresses, | for a host. The host argument is a string giving a host name or IP number. `---- so socket.gethostbyaddr(os.environ['REMOTE_ADDR'])[0] is the 0th element of the tuple, i.e. the *name* that is returned. So (unless I'm confused which is always a distinct possibility) this has nothing to do with load-balancing or multiple addresses: it's the equivalent of dig +short -x <addr> Nick
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-01-02 16:49 +0100
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-02 10:18 -0800
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Roy Smith <roy@panix.com> - 2012-01-02 13:42 -0500
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-02 11:51 -0800
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Roy Smith <roy@panix.com> - 2012-01-02 15:31 -0500
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-09 14:19 -0800
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Dominic Binks <dbinks@codeaurora.org> - 2012-01-09 14:35 -0800
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-09 15:04 -0800
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-01-10 07:42 +0100
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Chris Angelico <rosuav@gmail.com> - 2012-01-10 18:29 +1100
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Chris Angelico <rosuav@gmail.com> - 2012-01-10 10:14 +1100
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Nick Dokos <nicholas.dokos@hp.com> - 2012-01-09 18:32 -0500
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Chris Angelico <rosuav@gmail.com> - 2012-01-10 13:08 +1100
Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2012-01-02 11:54 -0800
csiph-web