[Top][All Lists]

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

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

From: Grant Edwards
Subject: Re: [lwip-users] How to set callback for accepted netconn connection?
Date: Mon, 22 Nov 2021 14:21:24 -0000 (UTC)
User-agent: slrn/1.0.3 (Linux)

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

> 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.


reply via email to

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