Bidirectional communication over unix socket (named pipe)
rridge at csclub.uwaterloo.ca
Thu Mar 9 09:46:20 CET 2006
Donn Cave wrote:
> The other part of the problem remains, as I don't know
> how to get data to actually go both ways.
The problem here is that datagram sockets don't send data from one
process to another, they send data from one address to another. In
this case, the client isn't able to receive data through it's socket
because the socket isn't bound any address. Calling connect() on the
datagram socket doesn't give the socket an address to receive data
with, just a default address to send data to. Since the server's
socket is the only socket bound to "/tmp/mysock" it's the only the only
process that can receive datagrams sent to that address. That includes
any datagrams the server itself sends to the address.
You need multiple Unix domain address so each process has an address it
can receive data with, and an address other than it's own that it can
send data to.
More information about the Python-list