How can I receive a Thread UDP packet from a network socket without using the Session module?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I receive a Thread UDP packet from a network socket without using the Session module?

1,275 Views
thomasblank
Contributor II

I am using the MCUXPresso SDK version 2.2 with the Thread stack on the KW41Z.

The manual says that in order to receive a packet on a UDP socket, I must register a Session callback, initilialize the Session task, a message queue, etc. I want to use just the simple recv() function.

When I try that, it does not seem to work. Also I can not see how I could give the function a timeout, or tell it to block until a packet comes in, or use a function like select() to find out when a packet arrives. It just immediately returns and gives me an error (-1).

Please explain how I should use the recv() function to receive UDP packets on a socket.

Tags (2)
0 Kudos
1 Reply

992 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello, 

When you are trying to send a message you will need to create the socket, bind it and create a connection. 

If you are trying to receive from a socket you will need to create a socket, bind the IP with a port and it will be listed, this is enabled by the #define SOCK_DEMO. 

If you want to see step by step the how to use UDP sockets on a Thread Host Controlled Device using SDK from MCUXpresso  you can check the following thread

Reboot will be caused immediately as soon as it received Socket Bind command for the TCP protocol + ...

Best Regards, 

Estephania 

0 Kudos