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. |
Beta Was this translation helpful? Give feedback.
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. |
Beta Was this translation helpful? Give feedback.
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.