I am very new to Socket programming, and I would appreciate any input you have in my question.
I am a physicist working on a project where the time intervals and coincidence of measurements play a big role. I have multiple measurement units connected to my laptop through Ethernet. The measurement units have a Linux kernel running with fortunately a Telnet server.
I implemented a scheme where the measurements are send to the laptop, to a specific port by all the units, and from the laptop the calculations are done. Each unit also get a response which request them to adjust parameters with respect to the calculations.
Currently I am running this setup with a 1s interval. Which would allow me to do receive data and apply corrections, from all the units in a reasonable manner.
But I would like to make all these measurements coinciding (currently it is a while
loop which checks everything one by one), and also scalable. I am thinking of using threading to accomplish this. But I have no idea how to sync them, or prevent errors like "this port is already bound". Is using multi-threading a good way? Or should I use any other approach?
I am using C and socket library to implement this.
TLDR : Multiple measurement unit are connected to the same port. I need to receive and respond to the units at the same time.