RandyGaul / cute_headers

Collection of cross-platform one-file C/C++ libraries with no dependencies, primarily used for games
4.28k stars 267 forks source link

cute_net.h Retry connecting after CN_CLIENT_STATE_CONNECTION_REQUEST_TIMED_OUT #305

Closed Siltnamis closed 2 years ago

Siltnamis commented 2 years ago

Hi, is there a way to use the same client_t to retry connecting to the same set of servers after client state becomes CN_CLIENT_STATE_CONNECTION_REQUEST_TIMED_OUT ? Scenario: Server is down client tries to connect with cn_client_connect client reaches timeout Server goes up client tries to connect with cn_client_connect cn_client_state_t never changes from CN_CLIENT_STATE_CONNECTION_REQUEST_TIMED_OUT even if cn_client_disconnect is called.

In this case should I destroy the client and create a new one?

RandyGaul commented 2 years ago

Yes that’s right. It’s possible to change the implementation to reuse the same client, but it wouldn’t really much different at all in terms of performance, and could possibly introduce bugs. So I don’t think it’s worth making a change.

Thanks for the question! I should make this kind of thing more obvious in the docs.

Going to close this issue, but feel free to comment or re-open it if needed!