summaryrefslogtreecommitdiffstats
path: root/Demo
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-11-08 17:24:34 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-11-08 17:24:34 (GMT)
commit06fd5f8cc854c79b5a4b113d7ef9ab01227d94cf (patch)
tree36c5625b8dcb782c92f6e67fc566659c3dda9fce /Demo
parentef6a19e3eab6dca9ef7eba92b636a4c2e88979c4 (diff)
downloadcpython-06fd5f8cc854c79b5a4b113d7ef9ab01227d94cf.zip
cpython-06fd5f8cc854c79b5a4b113d7ef9ab01227d94cf.tar.gz
cpython-06fd5f8cc854c79b5a4b113d7ef9ab01227d94cf.tar.bz2
fix the socketserver demo code for py3k
#4275 Thanks to Don MacMillen
Diffstat (limited to 'Demo')
-rwxr-xr-xDemo/sockets/udpecho.py3
-rw-r--r--Demo/sockets/unixclient.py2
2 files changed, 3 insertions, 2 deletions
diff --git a/Demo/sockets/udpecho.py b/Demo/sockets/udpecho.py
index 8a6bd21..9966fd8 100755
--- a/Demo/sockets/udpecho.py
+++ b/Demo/sockets/udpecho.py
@@ -56,7 +56,8 @@ def client():
line = sys.stdin.readline()
if not line:
break
- s.sendto(line, addr)
+ print('addr = ', addr)
+ s.sendto(bytes(line, 'ascii'), addr)
data, fromaddr = s.recvfrom(BUFSIZE)
print('client received %r from %r' % (data, fromaddr))
diff --git a/Demo/sockets/unixclient.py b/Demo/sockets/unixclient.py
index cdccb84..5e87eed 100644
--- a/Demo/sockets/unixclient.py
+++ b/Demo/sockets/unixclient.py
@@ -6,7 +6,7 @@ from socket import *
FILE = 'unix-socket'
s = socket(AF_UNIX, SOCK_STREAM)
s.connect(FILE)
-s.send('Hello, world')
+s.send(b'Hello, world')
data = s.recv(1024)
s.close()
print('Received', repr(data))