mirror of https://github.com/python/cpython
Someone found the examples of poor practice on socket addresses!
Spotted by Greg Kochanski <gpk@bell-labs.com>.
This commit is contained in:
parent
25871c001f
commit
3d69c0e440
|
@ -413,7 +413,7 @@ from socket import *
|
||||||
HOST = '' # Symbolic name meaning the local host
|
HOST = '' # Symbolic name meaning the local host
|
||||||
PORT = 50007 # Arbitrary non-privileged server
|
PORT = 50007 # Arbitrary non-privileged server
|
||||||
s = socket(AF_INET, SOCK_STREAM)
|
s = socket(AF_INET, SOCK_STREAM)
|
||||||
s.bind(HOST, PORT)
|
s.bind((HOST, PORT))
|
||||||
s.listen(1)
|
s.listen(1)
|
||||||
conn, addr = s.accept()
|
conn, addr = s.accept()
|
||||||
print 'Connected by', addr
|
print 'Connected by', addr
|
||||||
|
@ -430,7 +430,7 @@ from socket import *
|
||||||
HOST = 'daring.cwi.nl' # The remote host
|
HOST = 'daring.cwi.nl' # The remote host
|
||||||
PORT = 50007 # The same port as used by the server
|
PORT = 50007 # The same port as used by the server
|
||||||
s = socket(AF_INET, SOCK_STREAM)
|
s = socket(AF_INET, SOCK_STREAM)
|
||||||
s.connect(HOST, PORT)
|
s.connect((HOST, PORT))
|
||||||
s.send('Hello, world')
|
s.send('Hello, world')
|
||||||
data = s.recv(1024)
|
data = s.recv(1024)
|
||||||
s.close()
|
s.close()
|
||||||
|
@ -438,5 +438,5 @@ print 'Received', `data`
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
\begin{seealso}
|
\begin{seealso}
|
||||||
\seemodule{SocketServer}{classes that simplify writing network servers}
|
\seemodule{SocketServer}{classes that simplify writing network servers}
|
||||||
\end{seealso}
|
\end{seealso}
|
||||||
|
|
Loading…
Reference in New Issue