Guido van Rossum | 44f5c75 | 1998-01-29 04:04:04 +0000 | [diff] [blame] | 1 | # Echo server demo using Unix sockets (handles one connection only) |
2 | # Piet van Oostrum | ||||
Guido van Rossum | dd918a9 | 1998-01-28 16:54:00 +0000 | [diff] [blame] | 3 | from socket import * |
4 | FILE = 'blabla' | ||||
5 | s = socket(AF_UNIX, SOCK_STREAM) | ||||
6 | s.bind(FILE) | ||||
7 | print 'Sock name is: ['+s.getsockname()+']' | ||||
8 | s.listen(1) | ||||
9 | conn, addr = s.accept() | ||||
10 | print 'Connected by', addr | ||||
11 | while 1: | ||||
12 | data = conn.recv(1024) | ||||
13 | if not data: break | ||||
14 | conn.send(data) | ||||
15 | conn.close() |