I was able to use Mel Script to call python functions to connect to a socket. Connecting, sending and receiving works but I cannot close the socket and disconnect from server. The closing part is what bugs me. The closing function doesn't seem to be doing anything and I want to ask if anyone knows why or if this is a bug. I am using Maya 2016. The code is below.
python("import socket");
python("host = 'localhost'");
python("port = 7070");
python("client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)");
python("client.connect((host,port))");
//Set 4 seconds timeout
python("client.settimeout(4)");
python("client.send("Test");
string $receivedData = python("client.recv(1000)");
print ($receivedData);
python("client.close()");
The last line "python("client.close()");" is the part that doesn't work. I even tried running them on python directly instead of Mel script but I kept getting the same result. It just wont disconnect from the server. Any one got any ideas?