Note that there are some explanatory texts on larger screens.

plurals
  1. POC / how to bind multiple sockets for incoming and outgoing data
    text
    copied!<p>I discovered a problem in my code when I try to bind multiple sockets. I try to explain the situation, I have an application consisting of two parts, one is written in C running on machine_1, the other one is in Java running on machine_2. The C program should be able to send udp-packets through one port to 4 ports on the machine_2 which is listening on them. Vice versa machina_2 should send udp-packets through one outgoing port to 4 corresponding ports on machine_1.</p> <p>The problem I have is on machine_1:</p> <ol> <li>I have two threads there, one processing outgoing data to machine_2 and one processing the incoming data. Within the first thread (processing outgoing data) I create 4 sockets (with 4 different ports) to address the corresponding sockets on machine_2. Works fine in that direction...</li> <li>But when I try to create the sockets for the incoming data from machine_2, and I want to use the same port numbers as I did for incoming data on machine_2, but then I run into problems when I try to bind the sockets. Giving me the <code>: Address already in use</code> error.</li> </ol> <p>I need some help on how to set up the socket configuration on machine_1 inside the C application for outgoing and incoming ports. And maybe an example on how to use the <code>select()</code> function to listen on all 4 incoming sockets.</p> <p>If come code examples needed, I can add them here, but as I said it is only working for the thread_1 which handles the outgoing data through one socket to 4 different sockets on machine_2.</p> <p>Thanks in advance for your help!</p> <p>I hope the attached picture can explain the situation little bit more, important is that I want to use the same port numbers on both machines for incoming data. Means, port_1 on machine_1 has same port number than port_1 on machine_2, and so on...<img src="https://i.stack.imgur.com/QqH03.png" alt="port_configuration"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload