Using UDP with receive - cannot make it work!
markh
Posts: 10
Hi Folks,
I'm trying to communicate with a Brightsign via UDP and thought that it would be convenient to try the UDP with receive mode (IP_UDP_2WAY). However after some struggling I've been unable to make it work.
Attached is a cut-down but functional program where I've used both methods (using IP_UDP_2WAY on its own, and using IP_UDP + a separate device as a IP_UDP listening server) that i believe _should_ be equivalent. To change the program from two way UDP to one way+ listening UDP server, you just comment out the #define __2WAY__ at the top of the program.
In practice, the 2way method fails and the 1way with server works. So I get responses from the Brightsign on UDP port 5011 when I have __2WAY__ commented out, and nothing when I am using the __2WAY__ define. Anyone have any idea what I'm trying to do here that is wrong or the way that i am doing it?
thanks
Mark
I'm trying to communicate with a Brightsign via UDP and thought that it would be convenient to try the UDP with receive mode (IP_UDP_2WAY). However after some struggling I've been unable to make it work.
Attached is a cut-down but functional program where I've used both methods (using IP_UDP_2WAY on its own, and using IP_UDP + a separate device as a IP_UDP listening server) that i believe _should_ be equivalent. To change the program from two way UDP to one way+ listening UDP server, you just comment out the #define __2WAY__ at the top of the program.
In practice, the 2way method fails and the 1way with server works. So I get responses from the Brightsign on UDP port 5011 when I have __2WAY__ commented out, and nothing when I am using the __2WAY__ define. Anyone have any idea what I'm trying to do here that is wrong or the way that i am doing it?
thanks
Mark
0
Comments
There is a big difference between the idea of a single port being the method of communication and two ports. The basic difference is there's a whole conversation going on behind the scenes between your device and your master. That conversation has to do with setting up the port between the two devices and negotiating all the under-the-hood details of the message.
a 2-way UDP is not the same as two UDP-with-return on a single port.
The way you describe it - the device responds back by opening a port on your master and then sending a response back. If you try to use the UDP-with-response, the end device may try to make a one-shot UDP connection but see the port is already busy and gives up.
Unless the device specifically says it accepts UPD-with-response you will probably need to use two ports: an outbound (Client) and inbound (server).