Guido van Rossum | dd918a9 | 1998-01-28 16:54:00 +0000 | [diff] [blame] | 1 | # Echo client demo using Unix sockets |
| 2 | # Piet van Oostrum |
Thomas Wouters | 73e5a5b | 2006-06-08 15:35:45 +0000 | [diff] [blame] | 3 | |
Guido van Rossum | dd918a9 | 1998-01-28 16:54:00 +0000 | [diff] [blame] | 4 | from socket import * |
Thomas Wouters | 73e5a5b | 2006-06-08 15:35:45 +0000 | [diff] [blame] | 5 | |
| 6 | FILE = 'unix-socket' |
Guido van Rossum | dd918a9 | 1998-01-28 16:54:00 +0000 | [diff] [blame] | 7 | s = socket(AF_UNIX, SOCK_STREAM) |
| 8 | s.connect(FILE) |
| 9 | s.send('Hello, world') |
| 10 | data = s.recv(1024) |
| 11 | s.close() |
Collin Winter | 6f2df4d | 2007-07-17 20:59:35 +0000 | [diff] [blame^] | 12 | print('Received', repr(data)) |