UNIX domain sockets problem

bowman bowman at montana.com
Sun Apr 8 10:21:21 EDT 2001


"Steven D. Arnold" <stevena at permanent.cc> wrote in message
news:mailman.986695451.17699.python-list at python.org...
> SERVER = socket(AF_UNIX, SOCK_DGRAM, 0)
> unlink("/home/stevena/socket")
> SERVER.bind("/home/stevena/socket")

this snippet if from the Python Library Reference in the 2.0 distro. Haven't
a clue why you are trying to bind a file, but that's not the way it works.

# Echo server program
import socket

HOST = ''                 # Symbolic name meaning the local host
PORT = 50007              # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
    data = conn.recv(1024)
    if not data: break
    conn.send(data)
conn.close()







More information about the Python-list mailing list