I suppose you mean "cancel the netconn accepting" as netconn_accept() is the blocking call, not netconn_listen()?

This has been covered numerous times on this list: The netconn and socket API is *not* designed to let one connection (or socket) be used simultaneously from more than one thread. One thread blocking and one calling xxx_close() involves two threads -> not supported!

Instead, register a callback for the listening netconn. When this callback is called with REVEIVE_PLUS (use a mutex or whatever you want to wait for it), call netconn_accept and it won't block. That's the way select() is implemented for the socket API.

You then only have to be able to cancle your waiting-for-the-callback from your other thread and you're done.

Simon


Bertrand Van Kempen wrote:
Hello,
I'm using the netconn API to implement a HTTP server.
All works fine but I don't found how to cancel the "netconn listening" to exit 
properly in my application.
I tried to call netconn_close and netconn_delete but the working thread still 
wait on netconn_accept(m_pConn);
Thanks in advance for your help, Bertrand van Kempen I do the following: I initialize an TCP connection from the main thread: m_pConn = netconn_new(NETCONN_TCP);

netconn_bind(m_pConn, IP_ADDR_ANY, 80)
netconn_listen(m_pConn);

and, from another thread I call the following in a loop:

while(m_bContinue)

{

struct netconn *newconn;

MTAL_DP("{");

newconn = netconn_accept(m_pConn);

if(newconn){

http_server_serve(newconn);

netconn_delete(newconn);

}

}

Then, I tried to do the following form the main thread:

m_bThreadContinue = false;

if(m_pConn)

{

netconn_close(m_pConn);

netconn_delete(m_pConn);
m_pConn = NULL;

}



_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users




_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to