Closed zatarus closed 3 years ago
Hello @zatarus, that's a good question,
At this point, wsServer has no routine that arbitrarily closes the client connection. A quick fix that you may have guessed is just call the close()
function passing the fd client, but this is not the correct way to do it.
The proper way would be for the server to send a close frame to the client and then initiate a closing handshake and only then terminate the connection; maybe I should work on it, since it's something really useful to have.
Hey @Theldus, that's good to know. I will probably signal the client with a 'close' message as a workaround (so it can be triggered from js side), until if any api becomes available. Cheers
Hey @zatarus,
I've made a PR (#13) that adds the routine ws_close_client
with the following signature:
int ws_close_client(int fd);
that receives a client fd
and returns 0 if success, -1 otherwise. I hope this routine meets your expectations, ;-).
Thank you @Theldus, I will be switching over to this function instead of telling clients to disconnect. Cheers!
Pardon me if an obvious question.. Having fd on hand, is there a way to manually close connection before client hits 'disconnect' ? Thank you