Skip to content Skip to sidebar Skip to footer

Php (or Python) Listen To Unix Domain Stream Socket

I need to create a script that listens to a unix socket and forward the incoming stream to a bot. The scripts are unable to connect. The issues seems to be related to the order of

Solution 1:

When I replace the listing process ...

sock.connect(server_address)

This does not listen but it connects. To listen use bind,listen and accept the same way as you would do with other listing sockets (TCP, UDP):

server_address = '/tmp/tg.sck'# Analogous to TCP (address, port) pair
os.unlink(server_address)
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.bind(server_address)
sock.listen(2)
c,_ = sock.accept()
print c.recv(512)

Post a Comment for "Php (or Python) Listen To Unix Domain Stream Socket"