i want to execute the following simple server code:
import socket
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 22331 # Reserve a port
s.bind((host, port)) # Bind to the port
s.listen(5) # Now wait for client connection.
while True:
c, addr = s.accept() # Establish connection with client.
print('Got connection from', addr)
c.send('Thank you for connecting')
c.close()
gives the following error while executing:
OSError: [Errno 99] Cannot assign requested address
why the OS cannot bind the specified port with the address?