I would like to establish an IPC connection between several processes on Linux. I have never used UNIX sockets before, and thus I don\'t know if this is the correct approach
You can solve the bind error with the following code:
int use = yesno;
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char*)&use, sizeof(int));
With UDP protocol, you must invoke connect()
if you want to use write()
or send()
, otherwise you should use sendto()
instead.
To achieve your requirements, the following pseudo code may be of help:
sockfd = socket(AF_INET, SOCK_DGRAM, 0)
set RESUSEADDR with setsockopt
bind()
while (1) {
recvfrom()
sendto()
}