This repository has been archived on 2025-08-18. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
GGS/python_client
2011-02-02 21:19:33 +01:00

28 lines
525 B
Python
Executable file

#!/usr/bin/env python
import sys
import socket
HOST = 'localhost' # The remote host
PORT = int(sys.argv[1]) # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send(
'Token: 1001\n\
Command: define\n\
Content-Type: text\n\
Content-Length: 40\n\
\n\
function helloWorld(x) {return x + 2 ;}')
fs = s.makefile()
data = fs.readline()
token = data.split(" ")[0]
print "Token:", token
s.send(token+" __echo 0 msg")
data = s.recv(1024)
print data
s.close()