Path: csiph.com!x330-a1.tempe.blueboxinc.net!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'socket': 0.05; 'involves': 0.07; 'bind': 0.09; 'mentions': 0.09; 'sockets': 0.09; 'programmer': 0.11; 'am,': 0.14; 'wrote:': 0.14; '0))': 0.16; 'common.': 0.16; 'rachel': 0.16; 'socket.': 0.16; 'subject:interface': 0.16; 'yes;': 0.16; 'tries': 0.16; 'before.': 0.19; 'tue,': 0.20; 'seems': 0.21; 'header:In-Reply-To:1': 0.22; 'right,': 0.22; 'ftp': 0.25; "i'm": 0.26; 'chris': 0.27; 'message- id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'server': 0.29; 'explicitly': 0.29; 'all.': 0.30; 'omitted': 0.31; 'called': 0.32; 'to:addr:python-list': 0.32; 'cases,': 0.33; 'case,': 0.36; 'data': 0.37; 'some': 0.37; 'assigned': 0.37; 'received:209.85': 0.37; 'useful': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'less': 0.38; 'but': 0.38; 'port': 0.38; 'used': 0.38; 'to:addr:python.org': 0.39; 'where': 0.39; 'received:209': 0.39; "it's": 0.40; 'header:Received:5': 0.40; 'allows': 0.40; 'unusual': 0.60; 'give': 0.61; '2011': 0.62; 'glad': 0.64; 'care': 0.67; '26,': 0.68; "(i've": 0.84; 'received:209.85.210.174': 0.84; 'received:mail-iy0-f174.google.com': 0.84; 'schrieb': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=ZqPvDg99GeoBJCsl4QjZmH+/lhrgk7ghHYQ2oF1RA2c=; b=qyWtU5qTi4rnu4cJuSoU72L56WCbvtEP780awh6AdQs3go7zzO9BfU1fjS5T5eA/1U +4Rg6kIWlCfyohZtHMxt72VgAiHpLpVd+NnCMz2bDzhu64UpcPTbOyer9K4oSmAQIcWA 74Q0/JEuCTJuseNjjXw5NU1d8m19o0kV7k27s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=XOUQX8Ax0703NOCtBwn5z65hswK8w0nWRBXrPpoO5IvI3cgZe1iurWYmKrc8LaXZWv 5KuGMKInWjgEqt5R7rSOM0nk0rhYM8MBomPTRXwf58iWykXHju7Ks8OstXJCa3nwTxGr w+3/hbpgYgED4Tc/uzvwJi6QtF6RT5+3aqV40= MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 26 Apr 2011 07:50:40 +1000 Subject: Re: sockets: bind to external interface 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.12 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: 25 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303768243 news.xs4all.nl 81481 [::ffff:82.94.164.166]:40421 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4003 On Tue, Apr 26, 2011 at 7:18 AM, Thomas Rachel wrote: > Am 25.04.2011 22:30, schrieb Chris Angelico: > >> If you don't care what port you use, you don't need to bind at all. >> That may be why it's not mentioned - the classic TCP socket server >> involves bind/listen/accept, and the classic TCP client has just >> connect; bind/connect is a lot less common. > > That is right, but I cannot see where he mentions the "direction" of the > socket. My fist thought was that he tries to have a server socket... > > (BTW: bind can be omitted on server sockets as well; listen() seems to > includes a bind(('', 0)) if not called explicitly before. In this case, the > port is assigned randomly. Can be useful in some cases, where the port > number is not fixed...) Yes; for FTP data sockets, it doesn't matter what the port is, as long as you tell the other end. Same as you can bind/connect, you can not-bind and listen/accept. This is why I'm glad the socket subsystem allows unusual behaviours (I've used bind/connect in a few places). Give the programmer the tools and let him do what he chooses! Chris Angelico