I have two processes and I need to send messages between them. Here's the first file:
import socket
from info import socket1_filename, socket2_filename
socket1 = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
socket1.bind(socket1_filename)
socket2 = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
socket2.connect(socket2_filename)
And here's the second file:
import socket
from info import socket1_filename, socket2_filename
socket1 = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
socket1.connect(socket1_filename)
socket2 = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
socket2.bind(socket2_filename)
And here's the info
module:
socket1_filename = '/tmp/socket1'
socket2_filename = '/tmp/socket2'
Of course this thing won't work, it's kind of a deadlock:
Traceback (most recent call last):
File "process1.py", line 7, in <module>
socket2.connect(socket2_filename)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 2] No such file or directory
So what is the way to implement simple interconnection between processes if I need to be able to send messages and receive them in both endpoints?