summaryrefslogtreecommitdiffstats
path: root/Demo/sockets/unixserver.py
diff options
context:
space:
mode:
Diffstat (limited to 'Demo/sockets/unixserver.py')
-rw-r--r--Demo/sockets/unixserver.py15
1 files changed, 11 insertions, 4 deletions
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)