warmcat / libwebsockets

canonical libwebsockets.org networking library
https://libwebsockets.org
Other
4.78k stars 1.49k forks source link

Any LWS function is available to check the connection is in progress or not #2742

Closed Rajasekhar-topgear closed 2 years ago

Rajasekhar-topgear commented 2 years ago

Hi Experts,

          Could you please let me know if any LWS function is available to check whether the WebSocket connection is in progress or not?

Thanks, Rajasekhar.

lws-team commented 2 years ago

Generally speaking you need to follow the callbacks on the wsi to understand its state. If you want a flag you can look at later you can keep your own flag that has the meaning you want. But it's often a sign of other problems if you don't know very well the state of the connection already. For example the connection can close at the socket level at any time, and then lws will destroy everything about the connection. If you think you're going to come along later asynchronously and ask it if it is "in progress" whatever that means, you may be in for a surprise because the whole thing is deleted already.