]> granicus.if.org Git - python/commitdiff
Add more whitespace; use a better socket name
authorAndrew M. Kuchling <amk@amk.ca>
Sat, 3 Jun 2006 23:59:36 +0000 (23:59 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Sat, 3 Jun 2006 23:59:36 +0000 (23:59 +0000)
Demo/sockets/unixclient.py
Demo/sockets/unixserver.py

index cccd617e97ab4b60db2d178ea813df0e7aabfd99..fdbcc7aec1e95320f88953e75016fc4a2b4b00f4 100644 (file)
@@ -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')
index 5eccabbe96c50f2895a6d95051a9360480f82124..b73f857b1bdcd0f354649f88ccb9e580b5f04045 100644 (file)
@@ -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)