|
|
|
|
|
by valenterry
1335 days ago
|
|
Depends on what you mean by IO. The http library can be used without IO (i.e. you give it a request and it gives you the response and potentially does some effect (but that's e.g. done through the async library). But it also includes functionality to bind to a port and listen to requests there in the way the async library (or maybe a streaming library) controls etc. > In Zig, I am using a TLS library that does not perform I/O, it just writes to writers and reads from readers, so using it with io_uring or DPDK or send/recv or pcap files requires 0 additional work. Of course. Now imagine you need backpressure (reactive streaming) and writer/reader interfaces don't support that. Can someone provide you a library that you import and then automatically the types of the TLS library change and it works with the new interfaces that it doesn't even know exist? Because that's what I'm talking about. |
|
I'm not sure how "write does not even return until the writing is done" can avoid handling backpressure.
Unfortunately, I have had to add calls to flush() to the TLS library because it was not made with buffered writers in mind. I guess instead of writing flush() a couple of times I could have written a library that wraps a pair of buffered writer and reader in a new reader which flushes the writer if necessary when you read it and wraps the TLS library so that the passed-in reader and writer are automatically wrapped by that new reader. This sounds like a bit much though, since the whole task was to call flush a couple times only during TLS handshakes only if flush was defined.