idempotent close
#200
|
Is there a performance reason for WebSocket.close() to throw an error if called twice? If not, it would be nice to have it idempotent by becoming a no-op instead of throwing an error. |
Answered by
ghost
Sep 26, 2019
Replies: 1 comment
|
This implementation is not written using a garbage collector so closing a socket releases it. Therefore you need to track this and update whatever data structures you have when you close. The error you get is really just a fallback emergency break to warn you your code is broken. You shouldn't use try catch ideally you should fix your usage. Remember - this library is written in C and C has a different memory management philosophy which does not use garbage collection. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This implementation is not written using a garbage collector so closing a socket releases it. Therefore you need to track this and update whatever data structures you have when you close. The error you get is really just a fallback emergency break to warn you your code is broken. You shouldn't use try catch ideally you should fix your usage.
Remember - this library is written in C and C has a different memory management philosophy which does not use garbage collection.