You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
414 B
25 lines
414 B
# Echo server demo using Unix sockets (handles one connection only)
|
|
# Piet van Oostrum
|
|
|
|
import os
|
|
from socket import *
|
|
|
|
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()
|
|
|
|
while True:
|
|
data = conn.recv(1024)
|
|
if not data:
|
|
break
|
|
conn.send(data)
|
|
|
|
conn.close()
|
|
os.unlink(FILE)
|