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

Skip to content

Commit ef52f60

Browse files
committed
Revise the examples not to use the "from socket import *", and adjust
one comment in the example for clarity.
1 parent 0fc6a67 commit ef52f60

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Doc/lib/libsocket.tex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,11 @@ \subsection{Example \label{socket-example}}
426426

427427
\begin{verbatim}
428428
# Echo server program
429-
from socket import *
429+
import socket
430+
430431
HOST = '' # Symbolic name meaning the local host
431-
PORT = 50007 # Arbitrary non-privileged server
432-
s = socket(AF_INET, SOCK_STREAM)
432+
PORT = 50007 # Arbitrary non-privileged port
433+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
433434
s.bind((HOST, PORT))
434435
s.listen(1)
435436
conn, addr = s.accept()
@@ -443,10 +444,11 @@ \subsection{Example \label{socket-example}}
443444

444445
\begin{verbatim}
445446
# Echo client program
446-
from socket import *
447+
import socket
448+
447449
HOST = 'daring.cwi.nl' # The remote host
448450
PORT = 50007 # The same port as used by the server
449-
s = socket(AF_INET, SOCK_STREAM)
451+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
450452
s.connect((HOST, PORT))
451453
s.send('Hello, world')
452454
data = s.recv(1024)

0 commit comments

Comments
 (0)