lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] How to set callback for accepted netconn connection?


From: address@hidden
Subject: Re: [lwip-users] How to set callback for accepted netconn connection?
Date: Mon, 22 Nov 2021 16:08:45 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2

Am 22.11.2021 um 15:21 schrieb Grant Edwards:
On 2021-11-22, goldsimon@gmx.de <goldsimon@gmx.de> wrote:
Am 19.11.2021 um 22:55 schrieb Grant Edwards:
After accepting a tcp connection with netconn_accept(listenconn,
&newconn), how does one set the callback function for newconn?

The callback gets copied from the listening connection.

I suspected that might be the case, but hadn't been able to find where
that happened in the source code. For some reason I thought it had to
be happening at the netconn layer, but now I see it happens in
api_msg.c::accept_function()

Well, that file *is* one half the netconn layer (the half running in
tcpip_thrad, not in the application threads).

Regards,
Simon


While it would probably not be a big problem to change the
netconn->callback member at that point, it's not currently
implemented.

There's no real need to change it. I assume that if I ignore events on
a netconn instance it can still be used in a normal blocking manner.

However, there would be a race condition: the callback may be called
right after accepting the underlying connection, but before an
application thread has pulled the new connection out of the
listener's acceptmbox. So there might be a time span where the
underlying TCP connection can receive data but you wouldn't have
changed the callback yet.

Being like that, we live with having one callback for all types of
connections in the socket layer.

There's nothing wrong with that, I just couldn't find any information
on how to set up callbacks for netconn server sockets.

--
Grant





_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]