Closed ghost closed 3 years ago
is_client should be changed to OUTBOUND, INBOUND, OUTBOUND_ERROR, (INBOUND_ERROR)
or similar to tell a better story about the opening cause, where OUTBOUND_ERROR would be connection error.
Maybe even a whole struct? It makes sense to have at least 3 different connection errors: DNS, TLS, SYSTEM.
Inspiration from Apple's Network.framework
It could be a bitfield like so:
OUTBOUND | ERROR | TLS -> this would be a connection error of TLS kind
Then you can easily check for what you are interested in:
if (reason & ERROR) { // oopsie here }
Or more detailed:
if (reason & (ERROR | TLS))
This is fixed by having a new event only for client connection errors
Allegedly there's a bug where on_open is called followed by on_close when connect failes. Needs to be checked.