File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
430431HOST = '' # 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)
433434s.bind((HOST, PORT))
434435s.listen(1)
435436conn, 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+
447449HOST = 'daring.cwi.nl' # The remote host
448450PORT = 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)
450452s.connect((HOST, PORT))
451453s.send('Hello, world')
452454data = s.recv(1024)
You can’t perform that action at this time.
0 commit comments