so I am trying to implement a UDP server that will wait for a message from a client and then send data to that client.
The problem is, I cannot find a way to get the port number of the UDP client that is sending a message to me.
I have created the socket like this:
Hi dFx, thank you very much for your reply.
Yes, in the end I solved it with the NBS library. Their UDP.Receiver has a structure that contains the remote IP and port - that way I could then establish a two way communication.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone,
so I am trying to implement a UDP server that will wait for a message from a client and then send data to that client.
The problem is, I cannot find a way to get the port number of the UDP client that is sending a message to me.
I have created the socket like this:
bound like this:
Now I imagine I receive a message here:
now m_clientInfo is of type UDP_REPLY which contains the IP address of the client. When I want to respond via SysSockSendToUdp I need to specify the destination port (of course).
In the documentation of sysScoket ( https://help.codesys.com/webapp/idx-SysSocket%20Implementation-lib;product=SysSocket%20Implementation;version=3.5.15.0 ) I could not find a receive method that would work on my UDP socket and give me a socketaddr type.
I hope someone can help me.
Best regards
Did you had a look at CAA Net Base Services ?
There's some UDP server that may help. Also have a look in codesys store for exemple project.
https://help.codesys.com/webapp/idx-CAA_NetBaseServices-lib;product=CAA_NetBaseServices;version=3.5.9.50
Last edit: dFx 2020-11-09
Hi dFx, thank you very much for your reply.
Yes, in the end I solved it with the NBS library. Their UDP.Receiver has a structure that contains the remote IP and port - that way I could then establish a two way communication.