Altera_Forum
Honored Contributor
21 years agoLWIP socket creation issue
LWIP socket creation issue
I currently have implemented an algorithm that allows two separate devices (using the same code) to create and maintain a socket that goes something like: TaskA { while (true) { If(Connection == false) Start Task B Wait X seconds If (Connection == false) Shutdown Socket Delete Task B } } Task B { socket() // Create socket connect() // try to connect to external device (be the client) // Be the server) If (ConnectionFailed) Bind() Listen() Accept() // blocks here until incoming req or task B is deleted by Task A // we will only get here if we accept an incoming socket request Connection = true } This mechanism allows either device to be server or client depending on who gets booted first or if the socket is lost, they will search for each other and recreate the socket. All is well until the 14th time task A creates task B, the call to listen() fails On closer examination the failure results from the follow sequence of calls: Listen() // in my app lwip_listen() // in sockets.c netconn_listen() // in api_lib.c if(conn->acceptmbox == SYS_MBOX_NULL) { conn->acceptmbox = sys_mbox_new(); if (conn->acceptmbox == SYS_MBOX_NULL) { return ERR_MEM; } …. The “return ERR_MEM†is being executed, based on a failure with the sys_mbox_new() call. The sys_mbox_new() makes a call to OSQCreate() which is failing, this uCOS call creates a message queue. Has anyone come across this issue? If this is a stack issue, I’d like to avoid just increasing the size, this would just be delaying the on set of the problem. Aiden