summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libsocket.tex
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-10-10 20:36:29 (GMT)
committerFred Drake <fdrake@acm.org>2000-10-10 20:36:29 (GMT)
commitef52f601ed235bb87767e32a18058b46f14ceb6d (patch)
tree93a1aa53a20d30c9dc8b5dfbdc9bf5baec786c3d /Doc/lib/libsocket.tex
parent0fc6a67307c46d893a5cfa52f391b8855e7ae140 (diff)
downloadcpython-ef52f601ed235bb87767e32a18058b46f14ceb6d.zip
cpython-ef52f601ed235bb87767e32a18058b46f14ceb6d.tar.gz
cpython-ef52f601ed235bb87767e32a18058b46f14ceb6d.tar.bz2
Revise the examples not to use the "from socket import *", and adjust
one comment in the example for clarity.
Diffstat (limited to 'Doc/lib/libsocket.tex')
-rw-r--r--Doc/lib/libsocket.tex12
1 files changed, 7 insertions, 5 deletions
diff --git a/Doc/lib/libsocket.tex b/Doc/lib/libsocket.tex
index f0b7f8b..b6024ef 100644
--- a/Doc/lib/libsocket.tex
+++ b/Doc/lib/libsocket.tex
@@ -426,10 +426,11 @@ socket it is listening on but on the new socket returned by
\begin{verbatim}
# Echo server program
-from socket import *
+import socket
+
HOST = '' # Symbolic name meaning the local host
-PORT = 50007 # Arbitrary non-privileged server
-s = socket(AF_INET, SOCK_STREAM)
+PORT = 50007 # Arbitrary non-privileged port
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
@@ -443,10 +444,11 @@ conn.close()
\begin{verbatim}
# Echo client program
-from socket import *
+import socket
+
HOST = 'daring.cwi.nl' # The remote host
PORT = 50007 # The same port as used by the server
-s = socket(AF_INET, SOCK_STREAM)
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send('Hello, world')
data = s.recv(1024)