Using public IP address in sockets
问题 I am new to socket programming. My sockets work with localhost or local ip. But why can't I create a socket server with my public ip? When I try to do this in python, it complains "cannot assign requested address". import socket s=socket.socket() host="address" port=5000 s.bind((host, port)) s.listen(5) while True: c, addr=s.accept() result=c.recv(1024) print(result.decode('utf-8')) c.send(""" test """.encode('utf-8')) c.close() My IP I got from this website:http://whatismyip.host/ 回答1: A