def SenderClient(nick): sock = connect() sendCmd(sock, "LOGIN %s\r\n" % nick) sendCmd(sock, "JOIN #foo\r\n") sendCmd(sock, "MSG #foo Hello!\r\n") sendCmd(sock, "PART #foo\r\n") sendCmd(sock, "LOGOUT\r\n") sock.close()
def ListenerClient(nick): global status sock = connect() sendCmd(sock, "LOGIN %s\r\n" % nick) sock.recv(1024) sendCmd(sock, "JOIN #foo\r\n") data = "" while 1: data = sock.recv(1024) if not data: break if data == "OK\r\n": continue if "GOTROOMMSG" in data: break print "[%s] %s" % (nick, data.strip()) sendCmd(sock, "PART #foo\r\n") sendCmd(sock, "LOGOUT\r\n") sock.close()
while 1: sock.send("x") sock.close() except: print "got exception!" print sys.exc_info() print "login w/2KB username..." try: sock = connect() cmd = "LOGIN " for i in range(1, 2048): cmd += "x" cmd += "\r\n" sendCmd(sock, cmd) data = sock.recv(1024) print "data = %s" % data sendCmd(sock, "JOIN #foo") data = sock.recv(1024) print "data = %s" % data sock.close() except: print "got exception!" print sys.exc_info() print "normal read, just to see if the next select() is ok" try: sock = connect() sendCmd(sock, "LOGIN foo\r\n")
def NormalOp(i): print "Go! %d"%i sock = connect() sendCmd(sock, "LOGIN foo%d\r\n" % i) sendCmd(sock, "JOIN #foo\r\n") sendCmd(sock, "MSG #foo hello\r\n") sendCmd(sock, "MSG foo%d sup\r\n" % i) sendCmd(sock, "PART #foo\r\n") sendCmd(sock, "LOGOUT\r\n") disconnect(sock)
from threading import Thread def NormalOp(i): print "Go! %d"%i sock = connect() sendCmd(sock, "LOGIN foo%d\r\n" % i) sendCmd(sock, "JOIN #foo\r\n") sendCmd(sock, "MSG #foo hello\r\n") sendCmd(sock, "MSG foo%d sup\r\n" % i) sendCmd(sock, "PART #foo\r\n") sendCmd(sock, "LOGOUT\r\n") disconnect(sock) # normal operation for i in range(0, 10000): NormalOp(i) # quit by just closing the connection for i in range(0, 10000): sock = connect() sendCmd(sock, "LOGIN foo%d\r\n" % i) sendCmd(sock, "JOIN #foo\r\n") sendCmd(sock, "MSG #foo hello\r\n") sendCmd(sock, "MSG foo%d sup\r\n" % i) disconnect(sock) # 50 threads all connecting and operating normally for j in range(0, 10000): for i in range(0, 50): Thread(target=NormalOp, args=(i,)).start()
sock = connect() while 1: sock.send("x") sock.close() except: print "got exception!" print sys.exc_info() print "login w/2KB username..." try: sock = connect() cmd = "LOGIN " for i in range(1, 2048): cmd += "x" cmd += "\r\n" sendCmd(sock, cmd) data = sock.recv(1024) print "data = %s" % data sendCmd(sock, "JOIN #foo") data = sock.recv(1024) print "data = %s" % data sock.close() except: print "got exception!" print sys.exc_info() print "normal read, just to see if the next select() is ok" try: sock = connect() sendCmd(sock, "LOGIN foo\r\n") sendCmd(sock, "LOGOUT\r\n")
def NormalOp(i): print "Go! %d" % i sock = connect() sendCmd(sock, "LOGIN foo%d\r\n" % i) sendCmd(sock, "JOIN #foo\r\n") sendCmd(sock, "MSG #foo hello\r\n") sendCmd(sock, "MSG foo%d sup\r\n" % i) sendCmd(sock, "PART #foo\r\n") sendCmd(sock, "LOGOUT\r\n") disconnect(sock)
def NormalOp(i): print "Go! %d" % i sock = connect() sendCmd(sock, "LOGIN foo%d\r\n" % i) sendCmd(sock, "JOIN #foo\r\n") sendCmd(sock, "MSG #foo hello\r\n") sendCmd(sock, "MSG foo%d sup\r\n" % i) sendCmd(sock, "PART #foo\r\n") sendCmd(sock, "LOGOUT\r\n") disconnect(sock) # normal operation for i in range(0, 10000): NormalOp(i) # quit by just closing the connection for i in range(0, 10000): sock = connect() sendCmd(sock, "LOGIN foo%d\r\n" % i) sendCmd(sock, "JOIN #foo\r\n") sendCmd(sock, "MSG #foo hello\r\n") sendCmd(sock, "MSG foo%d sup\r\n" % i) disconnect(sock) # 50 threads all connecting and operating normally for j in range(0, 10000): for i in range(0, 50): Thread(target=NormalOp, args=(i, )).start()