telnet - break except: print 'Error getting readline' def...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #!/soft/python-2.4-bin/python import socket, sys, os, threading, time, string host = sys.argv[1] port = int(sys.argv[2]) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) buf = sock.makefile('rw', 0) def sendthread(): while 1: try: message = raw_input() message = message + '\r\n' sock.sendall( message )
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: break except: print 'Error getting readline' def recvthread(): while True: sys.stdout.write( buf.readline() ) firstT = threading.Thread(target = sendthread, name = "Sending Thread") secondT = threading.Thread(target = recvthread, name = "Receiving Thread") firstT.start() secondT.start() sock.close()...
View Full Document

This note was uploaded on 04/09/2008 for the course CSCI 4211 taught by Professor Sturtivant during the Spring '08 term at Minnesota.

Ask a homework question - tutors are online