[Python-checkins] r46634 - python/trunk/Demo/sockets/unixclient.py python/trunk/Demo/sockets/unixserver.py

andrew.kuchling python-checkins at python.org
Sun Jun 4 01:59:36 CEST 2006


Author: andrew.kuchling
Date: Sun Jun  4 01:59:36 2006
New Revision: 46634

Modified:
   python/trunk/Demo/sockets/unixclient.py
   python/trunk/Demo/sockets/unixserver.py
Log:
Add more whitespace; use a better socket name

Modified: python/trunk/Demo/sockets/unixclient.py
==============================================================================
--- python/trunk/Demo/sockets/unixclient.py	(original)
+++ python/trunk/Demo/sockets/unixclient.py	Sun Jun  4 01:59:36 2006
@@ -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')

Modified: python/trunk/Demo/sockets/unixserver.py
==============================================================================
--- python/trunk/Demo/sockets/unixserver.py	(original)
+++ python/trunk/Demo/sockets/unixserver.py	Sun Jun  4 01:59:36 2006
@@ -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)


More information about the Python-checkins mailing list