[En-Nut-Discussion] NutUdpReceiveFrom blocks in a thread

Coleman Brumley cbrumley at gopolar.com
Thu May 27 15:43:41 CEST 2010


Hello,

 

I have a situation where I'm attempting to use NutUdpReceiveFrom in a
thread.  However, the thread seems to be blocking on the call to
NutUdpReceiveFrom, even though I have a short timeout.  

 

Here's a snippet of my thread code:

 

char buff[1500];           //on the heap

 

THREAD(Rx,arg)

{

    int n;

    UDPSOCKET*s =(UDPSOCKET*)arg;

    printf("Starting Rx Thread...\n");

    for(;;)

    {

         n=NutUdpReceiveFrom(s,&fromaddr,&fromport,&buff,sizeof(buff),1);

         if(n<0)

         {

            NutThreadYield();

            continue;

         }

         printf("Got some data!\n");

    }

}

 

bool init(someport)

{

       sock=NutUdpCreateSocket(someport);

       NutThreadCreate("Rx",Rx,sock,sizeof(buff));

       NutUdpSendTo(sock,...); //to illustrate send and receive are on
different threads

}

 

The use of this thread causes the other threads in the system not to run.  I
don't even see the terminal output from the Rx Thread.  I would think stack
overflow, but none of the exception handlers are executing.  

 

Is there an issue with the thread safeness of NutUdpReceiveFrom?

 

Best Regards,

Coleman

 




More information about the En-Nut-Discussion mailing list