Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d69c0e

Browse files
committed
Someone found the examples of poor practice on socket addresses!
Spotted by Greg Kochanski <[email protected]>.
1 parent 25871c0 commit 3d69c0e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Doc/lib/libsocket.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ \subsection{Example}
413413
HOST = '' # Symbolic name meaning the local host
414414
PORT = 50007 # Arbitrary non-privileged server
415415
s = socket(AF_INET, SOCK_STREAM)
416-
s.bind(HOST, PORT)
416+
s.bind((HOST, PORT))
417417
s.listen(1)
418418
conn, addr = s.accept()
419419
print 'Connected by', addr
@@ -430,13 +430,13 @@ \subsection{Example}
430430
HOST = 'daring.cwi.nl' # The remote host
431431
PORT = 50007 # The same port as used by the server
432432
s = socket(AF_INET, SOCK_STREAM)
433-
s.connect(HOST, PORT)
433+
s.connect((HOST, PORT))
434434
s.send('Hello, world')
435435
data = s.recv(1024)
436436
s.close()
437437
print 'Received', `data`
438438
\end{verbatim}
439439

440440
\begin{seealso}
441-
\seemodule{SocketServer}{classes that simplify writing network servers}
441+
\seemodule{SocketServer}{classes that simplify writing network servers}
442442
\end{seealso}

0 commit comments

Comments
 (0)