0

I have a program in Python running on one AWS EC2 instance, trying to connect and communicate via sockets to other instances, that looks like so:

list = [IP1, IP2, IP3]
for IP in list:
    socket.connect(IP, portNumber)
    socket.sendall(data)

    response = socket.recv(2048)

    print(response)

The code connects fine to the first IP address. It gets a response and prints it alright. Once it hits the second iteration of the connect code, in the above example this would be:

socket.connect(IP2)

it throws

OSError: Transport endpoint already connected

and refuses to connect to the IP2 system, shutting down the program.

Any help would be appreciated! Thank you!

4

0 回答 0