# Thomas Heller 20060109 # Start this script on the PC, then start client.py on the Pocket PC. import socket, sys, threading import wincerapi # Initialise RAPI wincerapi.CeRapiInitTimeout() # Start the client program on the device DEVICE_PYTHON_EXE = '\\Program Files\\Python\\python.exe' DEVICE_SCRIPT = '\\my documents\\python\\pyceclient.py' wincerapi.RunProcess(DEVICE_PYTHON_EXE, '"' + DEVICE_SCRIPT + '"') HOST = '' # Symbolic name meaning the local host PORT = 20000 # Arbitrary non-privileged port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(1) conn, addr = s.accept() def get_input(): while 1: data = raw_input() conn.send(data + '\n') t = threading.Thread(target=get_input) t.setDaemon(True) t.start() while 1: data = conn.recv(1024) if not data: print "SystemExit, hit return to end." raise SystemExit sys.stderr.write(data)