Refactored the code of the embedded client so that it can now respond inside the same socket as the one it is receiving data from, even from another thread. Overrode some TCPServer method, added a new type of message carrying a socket with it, refactored some methods, minors fixes at the same time (please inherit from object). Hopefully did not break anything. Tested and it responds in the same socket and closes it well :)