[lwip-users] netconn_accept

128 views
Skip to first unread message

Sirjee Rooplall

unread,
Mar 29, 2012, 5:47:31 AM3/29/12
to Mailing list for lwIP users

Hi,

 

I am using LWIP version 1.3.2, ATMEL UC3A port with freeRTOS.

 

I have to develop an application that acts as a server listening for a connection from a client.

 

Each of the clients is setup to connect to the server using the exact port number.

 

Example:

Client1 -> Connects to 192.168.0.1 port=1234

Client2 -> Connects to 192.168.0.1 port=1234

Client3 -> Connects to 192.168.0.1 port=1234

 

Under freeRTOS I have created 3 Tasks, each of the Tasks, bind and listen for a connection on port 1234.

 

Here is my problem.

 

When Task 1 is created it binds and listens to accept a connection from port 1234 using netconn_accept, this works fine.

But when Task 2 and 3 are created to listen to the same port, netconn_accept returns an error:

 

LWIP_ERROR("netconn_accept: invalid acceptmbox", (conn->acceptmbox != SYS_MBOX_NULL), return NULL;);

 

How do I resolve this problem.

 

Kind regards 

Sirjee. Rooplall

(Software Engineer)

 

 

 

 

 

 

 

 

image002.emz
image004.png

gold...@gmx.de

unread,
Mar 29, 2012, 1:16:06 PM3/29/12
to Mailing list for lwIP users
Sirjee Rooplall wrote:
Under freeRTOS I have created 3 Tasks, each of the Tasks, bind and listen for a connection on port 1234.

That's not a problem in netconn_accept(): netconn_bind() will have returned an error before, as only one netconn (or pcb or socket, that doesn't depend on the API used or even the IP stack used) can bind to a port at a time. That's because TCP connections have to be uniquely identified by local address+port, remote address+port; a listening pcb does not have remote address+port and can thus cannot be uniquely identified if there's a second listening connection on the same port.

You'd have to create one central accepting thread that passes incoming connections to other threads to solve this.

Simon
Reply all
Reply to author
Forward
0 new messages