ok, wait a moment.
I re-read the thread and I noticed (only now, sorry for this) that you have the socket open with SOCK_DGRAM which is UDP and not TCP.
SO, try to use SOCK_STREAM instead.
Second, I've noticed that it seems you have the python code BOTH for server and client socket, which is correct if is the python script that acts as server (but in my code was the B4A that acts as server).
Anyway, in your py-server - the piece of code where is the line
print ("Test server listening on port {0}\n".format(PORT_NUMBER)
I don't see any mySocket.Listen(n) (where n is the max number of allowed connection, 1 is enough in your case)
But you say that you want to replace that part of code, so: who cares.
At this moment just replace SOCK_DGRAM with SOCK_STREAM and see what happens.
Just another question: are you sure the python client code works? Shoudn't it be something like:
mySocket = socket( AF_INET, SOCK_STREAM ) -> here I changed from UDP to TCP
MySocket.connect((HOST, PORT))
mySocket.send('cool')
- never see the sendto construct in python (maybe means connect + send...)