I have this script:
import threading, socket
for x in range(800)
send().start()
class send(threading.Thread):
def run(self):
while True:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("www.google.it", 80))
s.send ("test")
print ("Request sent!")
except:
pass
And at the place of "Request sent!" I would like to print something like: "Request sent! %s" % (the current number of the thread sending the request)
What's the fastest way to do it?
--SOLVED--
import threading, socket
for x in range(800)
send(x+1).start()
class send(threading.Thread):
def __init__(self, counter):
threading.Thread.__init__(self)
self.counter = counter
def run(self):
while True:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("www.google.it", 80))
s.send ("test")
print ("Request sent! @", self.counter)
except:
pass