~ubuntu-branches/ubuntu/saucy/python2.7/saucy-proposed

« back to all changes in this revision

Viewing changes to Doc/howto/sockets.rst

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-05-15 19:15:16 UTC
  • mto: (36.1.23 sid)
  • mto: This revision was merged to the branch mainline in revision 87.
  • Revision ID: package-import@ubuntu.com-20130515191516-zmv6to904wemey7s
Tags: upstream-2.7.5
ImportĀ upstreamĀ versionĀ 2.7.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
   serversocket.listen(5)
89
89
 
90
90
A couple things to notice: we used ``socket.gethostname()`` so that the socket
91
 
would be visible to the outside world. If we had used ``s.bind(('', 80))`` or
92
 
``s.bind(('localhost', 80))`` or ``s.bind(('127.0.0.1', 80))`` we would still
93
 
have a "server" socket, but one that was only visible within the same machine.
 
91
would be visible to the outside world.  If we had used ``s.bind(('localhost',
 
92
80))`` or ``s.bind(('127.0.0.1', 80))`` we would still have a "server" socket,
 
93
but one that was only visible within the same machine.  ``s.bind(('', 80))``
 
94
specifies that the socket is reachable by any address the machine happens to
 
95
have.
94
96
 
95
97
A second thing to note: low number ports are usually reserved for "well known"
96
98
services (HTTP, SNMP etc). If you're playing around, use a nice high number (4