Here is the code where the main error shows up
A bind with my local IP will work:
s.bind(("192.168.1.4", port))
A bind with my public IP fails with the error below
s.bind(("99.99.99.99", port))
[WinError 10049] The requested address is not valid in its context
Here is more context about my code:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = 6767
try:
s.bind(("192.168.1.4", port)) # will work fine as local ip is used but
# when used public ip the error is thrown
except socket.error as e:
print(str(e)+"aa")
s.listen(2)