Para cualquier otra persona con el mismo problema, probablemente sería mucho mejor usar sockets python.
Algún código de ejemplo que resolvería el problema en esta pregunta:
import socket
#AF_INET for IPv4, SOCK_STREAM for TCP (as opposed to UDP).
clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Tell the socket what IP and port number to connect to (must be in two brackets because it needs a tuple).
clientsocket.connect(('example.com', 1234))
#Recieve 1024 bytes of data.
data = clientsocket.recv(1024)
#Split the recieved data by newlines (returns a list).
data = data.split('\n')
#The first and second elements in our list should be the two numbers we need to add together, so we do that.
result = int(data[0]) + int(data[1])
#Send our result to the server.
clientsocket.send(str(result))
#Recieve any response from the server and print it to the screen.
data = clientsocket.recv(1024)
print data