Previously the socket object could be left unclosed if something in the `try:... except:...` block failed before reaching the line.
In theory this should not cause any issue, as the documentation of the `socket` library states that:
> Sockets are automatically closed when they are garbage-collected, but it is recommended to close() them explicitly, or to use a with statement around them.
But it resulted in worrying warnings being logged.
```
electrum/electrumabc_plugins/fusion/plugin.py:426: ResourceWarning: unclosed <socket.socket fd=3, family=2, type=1, proto=0, laddr=('127.0.0.1', 60508)>
if is_tor_port(host, port):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
```
Also move code lines that are never expected to error out of the `try: except:` scope, and use `hasattr` to detect the socket monkeypatching.