source: python/vendor/Python-2.7.6/Demo/sockets/unixserver.py

Last change on this file was 2, checked in by Yuri Dario, 15 years ago

Initial import for vendor code.

  • Property svn:eol-style set to native
File size: 414 bytes
Line 
1# Echo server demo using Unix sockets (handles one connection only)
2# Piet van Oostrum
3
4import os
5from socket import *
6
7FILE = 'unix-socket'
8s = socket(AF_UNIX, SOCK_STREAM)
9s.bind(FILE)
10
11print 'Sock name is: ['+s.getsockname()+']'
12
13# Wait for a connection
14s.listen(1)
15conn, addr = s.accept()
16
17while True:
18 data = conn.recv(1024)
19 if not data:
20 break
21 conn.send(data)
22
23conn.close()
24os.unlink(FILE)
Note: See TracBrowser for help on using the repository browser.