-
Notifications
You must be signed in to change notification settings - Fork 117
[feature] Expose a method to close the socket #193
Description
Since _sock is a "weakly private" member variable of **Client objects, if a user needs to close the socket, they have to be slightly impolite and access _sock.
So it would probably be good to expose a function to close it.
Why would a user need to close a socket?
The case I just ran into is this: I'm using Beeware (it doesn't matter which UI framework, though) to make a little app that will send OSC. The user will type the IP address into an input box. If there was a previously existing SimpleUDPClient and the user has typed a new IP address or port, creating a new SimpleUDPClient causes the old one to become unreachable, and when it's destroyed, there will be a warning about an unclosed resource. To avoid this error, I need to close the socket before creating the new one. This was undocumented; I found _sock only by reading the source code.
Doing self.udpClient._sock.close() in my code works, though it may be slightly rude, so the feature request is for a less rude way to do this.