Staging
v0.5.1
https://github.com/python/cpython
Revision 836b670e893a78cd3fc585aad71875a4bdf1a0a9 authored by Amaury Forgeot d'Arc on 20 November 2008, 23:53:46 UTC, committed by Amaury Forgeot d'Arc on 20 November 2008, 23:53:46 UTC
The code still mixed bytes and strings.

Reviewed by Martin von Loewis.
1 parent 9d24ff0
Raw File
Tip revision: 836b670e893a78cd3fc585aad71875a4bdf1a0a9 authored by Amaury Forgeot d'Arc on 20 November 2008, 23:53:46 UTC
#4338: Fix the distutils "setup.py upload" command.
Tip revision: 836b670
unixserver.py
# 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)
back to top