Be aware that double closing sockets can lead to a crash: Big Sur ServerSocket Trouble - #7 by Mike_D