xxxxxxxxxx
If you'd like to let the other party know that you're closing the connection, you can use
# s is a socket.socket object
s.shutdown(socket.SHUT_RDWR)
s.close()
The flags argument to send has a different meaning, and may be used to send the MSG_OOB and MSG_DONTROUTE flags - see man send for the list.
Those flags would be used by doing:
s.send(data, flags=socket.MSG_OOB | socket.MSG_DONTROUTE)
Anyway in my opinion this will help you little bit to solve your problem
https://learnshareit.com/python-tutorial/