#!/usr/bin/python from socket import * from time import time, sleep from thread import start_new_thread, get_ident from os import system import sys def httptest(name,url): id = get_ident() j=0 while 1: j=j+1 i="%u,%u"%(id,j) print "%s,%s,started"%(name,i) t1=time() try: f=socket(AF_INET, SOCK_STREAM) f.connect(url) f.read(1024) f.close() except: print "%s,%s,failed,%s"%(name,i,sys.exc_value) t2=time() print "%s,%s,elapsed,%f"%(name,i,(t2-t1)) def test(name,url,count): for i in range(1,count): print "starting %s thread(%u,%u)"%(name,i,count) start_new_thread(httptest,(name,url)) test("rovid", ("192.168.131.149", 10000), 100) system("ping 192.168.131.149")