import time, sys, os
from socket import *
port = 50008 # i am client: use GUI server port
host = 'localhost' # start me after GUI started/spawned
os.startfile('gui.py') # spawn the GUI on Windows (alt: popen)
sock = socket(AF_INET, SOCK_STREAM)
sock.connect((host, port))
file = sock.makefile('w', 0) # file interface wrapper, unbuffered
sys.stdout = file # make prints go to sock.send
while 1: # non-gui code
print time.asctime() # sends to GUI process
time.sleep(2.0)