uNetworking / uSockets

Miniscule cross-platform eventing, networking & crypto for async applications
Apache License 2.0
1.29k stars 268 forks source link

us_socket_context_connect error reporting #25

Closed ghost closed 3 years ago

ghost commented 5 years ago

Allegedly there's a bug where on_open is called followed by on_close when connect failes. Needs to be checked.

ghost commented 5 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

ghost commented 5 years ago

29 DNS related failures should end up in on_open with error

ghost commented 5 years ago

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

ghost commented 3 years ago

This is fixed by having a new event only for client connection errors