From: Georg Brandl Date: Sun, 14 Apr 2013 08:59:04 +0000 (+0200) Subject: bind('') does not do the same as bind('localhost') X-Git-Tag: v3.3.2~113 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a204636b9190b8e69fe39b86291c2ba69913e310;p=python bind('') does not do the same as bind('localhost') --- diff --git a/Doc/howto/sockets.rst b/Doc/howto/sockets.rst index ca6528b06f..151e2c810d 100644 --- a/Doc/howto/sockets.rst +++ b/Doc/howto/sockets.rst @@ -84,9 +84,11 @@ creates a "server socket":: serversocket.listen(5) A couple things to notice: we used ``socket.gethostname()`` so that the socket -would be visible to the outside world. If we had used ``s.bind(('', 80))`` or -``s.bind(('localhost', 80))`` or ``s.bind(('127.0.0.1', 80))`` we would still -have a "server" socket, but one that was only visible within the same machine. +would be visible to the outside world. If we had used ``s.bind(('localhost', +80))`` or ``s.bind(('127.0.0.1', 80))`` we would still have a "server" socket, +but one that was only visible within the same machine. ``s.bind(('', 80))`` +specifies that the socket is reachable by any address the machine happens to +have. A second thing to note: low number ports are usually reserved for "well known" services (HTTP, SNMP etc). If you're playing around, use a nice high number (4