AsUDP Communication

Hello community,
I want to communicate simultaneously with 4 Devices via AsUDP.
Is it possiple to open more than one Connection with UdpOpen? I got the same ident when I open on the same Ethernetdevice a second UDP-Socket.
UdpConnect connects with the correct Destination-IP to the device, but the Instance of UdpClient points to the last opened and connected Device.
Is it possible to get an example how to connect and communicate at a time to more than one Udp-Device?
Thanks for anwering.

greetings
Frank

Hi,

I was curious and did some testing about UdpOpen() options I’ve never used before.
It looks like that by using the options udpOPT_REUSEADDR + udpOPT_REUSEPORT with UdpOpen() you could achive your goal using the same port with different remote station bindings by UdpConnect().

I called 3 UdpOpen() instances with the options mentioned above, bound 2 of the idents to 2 different remote stations + dedicated ports and left the third ident unbound.
Then I used all 3 idents from UdpOpen() for receiving data.

And voila, it looks like that the 2 bound sockets just received the data from the remote stations + port bound, and the 3rd socket received “anything else” that was sent to the open UDP port (for sure, the 3rd one is not mandatory for the use-case I understood, but was a nice-to-have to see what happens).

Hope that information helps to realize your use-case.
Best regards!

PS: if your use-case allows to open a different UDP port for each remote station, just forget everything above :wink: This is possible without the reusage of the same port, and even without connecting the port.

Hello Alexander,
thanks for your help. Now it works with the options: UDPClient.UdpOpen_0.options := udpOPT_REUSEADDR OR udpOPT_REUSEPORT;
For every UPD-Connection i have one instance. When starting, I allow only one UDP-Socket-Build at a time: UdpOpen_0() and then UdpConnect_0().
After that initialization the five instances work asynchoniously.
Greetings,
Frank

1 Like

Just to mention it but multicast adresses would also be an option to send one telegram to a group or receivers

2 Likes