#!/soft/python-2.4-bin/python import os, sys, time, socket, threading def main(): cx = socket.socket(socket.AF_INET, socket.SOCK_STREAM) cx.connect( ('localhost', 5001) ) flo = cx.makefile('r', 0) listener = threading.Thread(target=listen, name='listener', args=[flo, cx] ) listener.setDaemon(1) listener.start() talk(cx) def listen(flo, cx): while 1: try: print flo.readline(), except: flo.close() cx.close() return def talk(cx): while 1: try: cx.sendall( raw_input() + '\r\n' ) except: cx.close() return main()