i am trying to establish connections for multiple sockets using multi-threading
this is the code
import socket as sc
if __name__ == '__main__':
#setup()
ports = [10000, 10010, 10020, 10030]
init_sockets()
init_threads()
def init_sockets():
global host_ip
global sockets
host_ip = sc.gethostname()
sockets = []
for port in ports:
socket = sc.socket()
socket.bind((host_ip, port))
socket.listen()
sockets.append(socket)
def init_threads():
threads = [
threading.Thread(target= init_connection, args= [socket])
for socket in sockets
]
for thread in threads:
thread.start()
def init_connection(socket):
client, address = socket.accept()
while running the code this error appears
ConnectionAbortedError: [Errno 53] Software caused connection abort
the error occurs in thread.start()
statement in function init_threads()
i don't know why this is happening, and would really appreciate any help. i am trying to run multiple socket connections in parallel, if it's impossible this way, i am open to recommendations