Exemplo n.º 1
0
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()
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
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()
Exemplo n.º 5
0
    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")
Exemplo n.º 6
0
Arquivo: basic.py Projeto: unshift/ita
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)
Exemplo n.º 7
0
Arquivo: basic.py Projeto: unshift/ita
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()
Exemplo n.º 8
0
    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")
Exemplo n.º 9
0
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)
Exemplo n.º 10
0

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()