Python Networking

260 Views Asked by At

So I have create a socket and am using the function socket.bind() and keep on getting the following error: Only one usage of each socket address (protocol/network address/port) is normally permitted Here is my code:

import socket

s = socket.socket()
host = socket.gethostname()
port = 12345
s.bind((host, port))


s.listen(5)
while True:
    c , addr = s.accept()
    print('Thank you for connecting to', addr)
    c.send('Hello and thanks for connecting')
    c.close()
1

There are 1 best solutions below

0
On BEST ANSWER

The port / ip combination is bound already. You can not bind it again. You should check if an other instance of your program is still running. If not, use an other port.