Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 10 months ago.
UDP Socket Issue
Hello,
I am having a problem with the UDP Socket object. I am using an EA-LPC4088. Below is some example code where I am expecting the receiveFrom() method to timeout after 1000msec. However, it never times out if there is no packet traffic. Am I doing something wrong or is there an issue with the EthernetInterface class?
Regards,
Tom Doyle
Include EthernetInterface and mbed-rtos libs with with example
include "EthernetInterface.h" DigitalOut myled(LED1, 1); EthernetInterface gEth; UDPSocket gSocket; int main() { printf ("Starting Program\r\n"); if (gEth.init("195.0.0.6", "255.255.255.0", "195.0.0.1") < 0) { error("FATAL Error: Ethernet Initialization Error\r\n"); } if (gEth.connect(10000) < 0) { error("FATAL Error: Ethernet Connection Error\r\n"); } if (gSocket.bind(4323)) { error("FATAL Error: Unable to bind ALXT_MSG_PORT socket"); } gSocket.set_broadcasting(true); //gSocket.set_blocking(true, 1000); Endpoint source; char receiveBuf[512]; while(1) { gSocket.receiveFrom(source, (char*)receiveBuf, sizeof(receiveBuf)); myled = !myled.read(); } }