diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2006-06-03 23:59:36 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2006-06-03 23:59:36 (GMT) |
commit | 9fef9b166e724f404ec9c0096d106194f37da857 (patch) | |
tree | 92c0b029a493f0849bfbf93e22f5357f276ac2c3 /Demo | |
parent | 46df918314b31c58ecf8eb01b5bed9d6ead87cd4 (diff) | |
download | cpython-9fef9b166e724f404ec9c0096d106194f37da857.zip cpython-9fef9b166e724f404ec9c0096d106194f37da857.tar.gz cpython-9fef9b166e724f404ec9c0096d106194f37da857.tar.bz2 |
Add more whitespace; use a better socket name
Diffstat (limited to 'Demo')
-rw-r--r-- | Demo/sockets/unixclient.py | 4 | ||||
-rw-r--r-- | Demo/sockets/unixserver.py | 15 |
2 files changed, 14 insertions, 5 deletions
diff --git a/Demo/sockets/unixclient.py b/Demo/sockets/unixclient.py index cccd617..fdbcc7a 100644 --- a/Demo/sockets/unixclient.py +++ b/Demo/sockets/unixclient.py @@ -1,7 +1,9 @@ # Echo client demo using Unix sockets # Piet van Oostrum + from socket import * -FILE = 'blabla' + +FILE = 'unix-socket' s = socket(AF_UNIX, SOCK_STREAM) s.connect(FILE) s.send('Hello, world') diff --git a/Demo/sockets/unixserver.py b/Demo/sockets/unixserver.py index 5eccabb..b73f857 100644 --- a/Demo/sockets/unixserver.py +++ b/Demo/sockets/unixserver.py @@ -1,17 +1,24 @@ # Echo server demo using Unix sockets (handles one connection only) # Piet van Oostrum + import os from socket import * -FILE = 'blabla' + +FILE = 'unix-socket' s = socket(AF_UNIX, SOCK_STREAM) s.bind(FILE) + print 'Sock name is: ['+s.getsockname()+']' + +# Wait for a connection s.listen(1) conn, addr = s.accept() -print 'Connected by', addr -while 1: + +while True: data = conn.recv(1024) - if not data: break + if not data: + break conn.send(data) + conn.close() os.unlink(FILE) |