MCF52235 - Call to socket() fails

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

MCF52235 - Call to socket() fails

Jump to solution
1,635 Views
ArtyCF
Contributor II

Hello everyone,

I've been stuck for a while now on a problem trying to create a socket.
I have an application consisting of two tasks (lets call them Task A and Task B).  Task A is the main task, automatically  started by MQX.  Task A initializes RTCS, sets up the Ethernet device, obtains an IP address using DHCP and creates and starts Task B.  Task B is supposed to create a socket and then listen for incoming remote connections.  One of the first things it does is attempt to create the listening socket by calling the RTCS socket() function.  However, this call never returns and worse, no other tasks appear to run after that.  If I break the execution and step through the code I can see that the program seems to be looping inside the MQX dispatcher.  Even the RTCS task is no longer running because I can't even ping my board.

If I try calling socket() in Task A there is no problem at all and a handle to a new socket is returned.

Am I missing something fundamental here?  I've run out of things to try and I can't find an example where a socket is created on a task that is not the same one that initialized RTCS.

Any help or suggestions would be greatly appreciated.

Thank you.

Labels (1)
Tags (1)
0 Kudos
1 Solution
564 Views
madifazio
Contributor III

Hi, 

How do you call the socket() function? Did you check the stack size of the task B?.

When you break the execution, can you see the status of Task B?

The priorities of the tasks seems to be ok.

View solution in original post

0 Kudos
4 Replies
564 Views
madifazio
Contributor III

Hi,

Check if the priority of the Task B is lower than the priority of the RTCS task.

Marcos

0 Kudos
564 Views
ArtyCF
Contributor II

Thanks Marcos.  I had wondered about that too because it looked like some form of deadlock.  I tried lowering the priorities of my two tasks but that didn't help.  In module "rtcsglob.c" the global parameter _RTCSTASK_priority is set to 6 so I assume that is the priority that the RTCS task is using.  My Task A and Task B have lower priorities of 10 and 9 respectively.

0 Kudos
565 Views
madifazio
Contributor III

Hi, 

How do you call the socket() function? Did you check the stack size of the task B?.

When you break the execution, can you see the status of Task B?

The priorities of the tasks seems to be ok.

0 Kudos
564 Views
ArtyCF
Contributor II

Apparently my Task B stack was too small at 500 bytes (in comparison Task A stack was 3000 bytes).  I increased the size of the Task B stack to 3000 bytes and now it works.  Somehow when I was looking for differences between the two tasks I missed that glaringly obvious fact :smileyhappy:.   I'm surprised that a call to socket() consumes so much of the stack but my background has mostly been with 8-bit microcontrollers where only a few hundred bytes are available.  I guess I've learned the hard way.

 

In any case, I'm finally moving forward again.  Thank you for your interest and suggestions Marcos, I'm grateful for all your help with this.

 

 

0 Kudos