Hi there,
my application needs at least 3 UDP sockets and I'm having trouble with it, I cannot create more than 3 sockets. I also found a post in the questions section, where someone reports the same with 3 TCP connections.
I made a small test program that attempts to start a thread, and inside the thread I call lwip_socket(AF_INET, SOCK_DGRAM, 0) - it works for 3 sockets, then fails.
After digging into the depths of the lwip things, I think the function tcpip_apimsg() fails, when it calls sys_mbox_valid(&mbox). I do not yet understand what this code does, "mbox" is a static variable, so why would the code work 3 times and then fails.
Can anyone confirm this behaviour ? Or is there anyone with more than 3 sockets ?
sample code
#include "mbed.h"
#include "EthernetInterface.h"
Serial pc (USBTX,USBRX);
void SocketThread(void const* args)
{
int aSocket;
aSocket = lwip_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDPLITE);
if (aSocket < 0)
pc.printf("-");
else
pc.printf("+");
while (true) osDelay(1001);
}
osThreadDef(SocketThread, osPriorityNormal, 512 );
static EthernetInterface interface;
int main()
{
pc.printf("\r\nHello netTest \r\n");
interface.init("172.16.2.162", "255.255.252.0", "0.0.0.0");
interface.connect();
osThreadId tid[16];
for (int i=0; i<8; i++)
{
tid[i] = osThreadCreate(osThread(SocketThread), (void*) i);
if (tid[i] == NULL) pc.printf("Failed to create a thread #%d \r\n", i);
osDelay(50);
}
pc.printf("\r\ndone \r\n");
while (true) wait(1.0);
}
Hi there,
my application needs at least 3 UDP sockets and I'm having trouble with it, I cannot create more than 3 sockets. I also found a post in the questions section, where someone reports the same with 3 TCP connections.
I made a small test program that attempts to start a thread, and inside the thread I call lwip_socket(AF_INET, SOCK_DGRAM, 0) - it works for 3 sockets, then fails.
After digging into the depths of the lwip things, I think the function tcpip_apimsg() fails, when it calls sys_mbox_valid(&mbox). I do not yet understand what this code does, "mbox" is a static variable, so why would the code work 3 times and then fails.
Can anyone confirm this behaviour ? Or is there anyone with more than 3 sockets ?
sample code