Mention Giampolo R's new FTP TLS support in the what's new file
[python.git] / Demo / sockets / unixserver.py
blobb73f857b1bdcd0f354649f88ccb9e580b5f04045
1 # Echo server demo using Unix sockets (handles one connection only)
2 # Piet van Oostrum
4 import os
5 from socket import *
7 FILE = 'unix-socket'
8 s = socket(AF_UNIX, SOCK_STREAM)
9 s.bind(FILE)
11 print 'Sock name is: ['+s.getsockname()+']'
13 # Wait for a connection
14 s.listen(1)
15 conn, addr = s.accept()
17 while True:
18 data = conn.recv(1024)
19 if not data:
20 break
21 conn.send(data)
23 conn.close()
24 os.unlink(FILE)