[Is it a typo that you use the script local pSocket also as paramName of handlers?]
This works on Mac here. What about "localhost" on your linux flavour?Use "localhost" or the hostnametoaddress of the hostname
What I meant with mentioning that is that you should get the server host by script so that it works for everybody who uses your script. If needed use a platform switch. Assuming you are preparing a demo

To your "close socket" notes.
May be the "unofficially reserved" port number 12345 on your local host is conflicting with your network settings/firewall?
12345 is unofficially reserved for NetBus remote administration tool (often Trojan horse). Also used by NetBuster, see https://en.wikipedia.org/wiki/List_of_T ... rt_numbers
There was also an 'upgrade' of "open socket" in 9.0, see the dictionary. May be the "close socket" wasn't adjusted accordingly?
As closing sockets by using the port number from "accept connections" worked until now always for me on all platforms I have no experience with "close socket" in other ways. If something is claimed in the dictionary but doesn't work, you should report that to LiveCode Quality Control Center.