For some limit of my design, I create and bind two sockets on same IP address and same port, each of the socket is created and bound in one process, using the socket option of SO_REUSEADDR . And my operating system doesn´t support child process or thread. I am using a IP stack based on BSD. I want the process with the first socket to be a packet sender and the process with the second socket to be a listener with a infinite loop of recv() called.
My assumption is that the both of the sockets can send packets to the remote address and the second bound socket can receive the packets from remote. But the result is that, the second socket can receive packets untill the first socket sends a packet out. After that, it seems that the sockets are switched, the second socket is inactive and can´t receive anything.
I am wondering if this is the correct behavior of BSD socket? And how sendto() function impact the BSD changing the socket configuration/setting for the sockets?
My assumption is that the both of the sockets can send packets to the remote address and the second bound socket can receive the packets from remote. But the result is that, the second socket can receive packets untill the first socket sends a packet out. After that, it seems that the sockets are switched, the second socket is inactive and can´t receive anything.
I am wondering if this is the correct behavior of BSD socket? And how sendto() function impact the BSD changing the socket configuration/setting for the sockets?