New lwIP-based Ethernet library for Teensy 4.1

One other minor thing I'd like to request: read(unsigned char*, size_t) for EthernetClient/EthernetUDP should have an overload that accepts void* to reduce casting all the time and to match the write/send methods.
There was a reason I added the void* output methods but not equivalent input methods. Now what was it again... maybe I just felt at the time that the semantic difference was important or something.
 
One other minor thing I'd like to request: read(unsigned char*, size_t) for EthernetClient/EthernetUDP should have an overload that accepts void* to reduce casting all the time and to match the write/send methods.
I'm curious what types of memory you're reading into and how you handle partial reads into something that isn't an unsigned char, i.e. the element type is bigger? Wouldn't you need to cast anyway? Do you think you could give me a code example where using a read(void*) form would be easier?
 
If a client is sending only fixed-sized messages and available() shows there is enough data available to fill one, I should be able to pass a pointer to a message directly to read(). A cast is necessary to uint8_t* but never required for void*.
 
If a client is sending only fixed-sized messages and available() shows there is enough data available to fill one, I should be able to pass a pointer to a message directly to read(). A cast is necessary to uint8_t* but never required for void*.
Yup, that's the use-case I was looking for. Thanks.
 
I'm curious what types of memory you're reading into and how you handle partial reads into something that isn't an unsigned char, i.e. the element type is bigger?
Also I did mention UDP, where this isn't applicable - as long as the element fits in a datagram, you either get the whole thing or none of it.
 
Is there any way to set SO_KEEPALIVE on an EthernetClient's socket? I can see it's implement in lwip / alt_tcp, but a) I don't think the required compile-time flag is on by default and b) there's no way to access the keepalive set/get functions through EthernetClient.
I'm using the Teensy to act as a server, clients have a habit of just "going away" and with no way to send keepalives or 0 byte transfers the sockets don't close and resources aren't released.
 
Is there any way to set SO_KEEPALIVE on an EthernetClient's socket? I can see it's implement in lwip / alt_tcp, but a) I don't think the required compile-time flag is on by default and b) there's no way to access the keepalive set/get functions through EthernetClient.
I'm using the Teensy to act as a server, clients have a habit of just "going away" and with no way to send keepalives or 0 byte transfers the sockets don't close and resources aren't released.
I can certainly look into adding an API for it when I have a chance.
 
Last edited:
Here's an update about what's in the pipeline (I've been dealing with some other things, so haven't had much chance to work on the library lately):
1. Much better memory use
2. Refactoring all the connection holder/state stuff because it's hard to follow and understand. That probably means there's bugs and maybe some race/ordering problems.
3. void* versions of peek() and read() in EthernetClient
4. TCP keepalive API support
5. Other bug fixes and improvements (eg. EthernetClient peek()-then-read() returning different values)
 
6. Related to #2, I think there's a potential use-after-free problem.

5 and 3 are solved, 1, 2, and 6 are on their way, and 4 is still in the pipeline.
 
Back
Top