Skip to content

[feature] Expose a method to close the socket #193

@jamshark70

Description

@jamshark70

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions