The `socket.connect` approach is clever and I can try it.  Context manager is a good idea too; I'll see if I can get my head around it properly.