Commit ef52f601 authored by Fred Drake's avatar Fred Drake

Revise the examples not to use the "from socket import *", and adjust

one comment in the example for clarity.
parent 0fc6a673
...@@ -426,10 +426,11 @@ socket it is listening on but on the new socket returned by ...@@ -426,10 +426,11 @@ socket it is listening on but on the new socket returned by
\begin{verbatim} \begin{verbatim}
# Echo server program # Echo server program
from socket import * import socket
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 port
s = socket(AF_INET, SOCK_STREAM) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT)) s.bind((HOST, PORT))
s.listen(1) s.listen(1)
conn, addr = s.accept() conn, addr = s.accept()
...@@ -443,10 +444,11 @@ conn.close() ...@@ -443,10 +444,11 @@ conn.close()
\begin{verbatim} \begin{verbatim}
# Echo client program # Echo client program
from socket import * import socket
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.socket(socket.AF_INET, socket.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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment