问题描述
因此,要开始端口转发,我将UPnPc与命令upnpc -a 10.0.0.21 10000 3333 TCP
一起使用(10.0.0.21 =内部IP)(10000 =内部端口)(3333 =外部端口)(TCP =方法),并获得成功消息表示已成功启动,并且可以通过给定的外部IP和端口进行连接。这是我的服务器代码:
sock = socket.socket(socket.AF_INET,socket.soCK_STREAM)
sock.bind((internal_IP,internal_Port))
sock.listen(1)
#the code then afterwards waits for connections and prints them
如果我随后使用客户端,我在python中编写了使用外部IP和外部端口进行连接的操作,则连接失败,表示连接被拒绝。但是,如果我使用内部IP和内部端口,那么一切都会正常进行。
这是我的客户代码:
sock = socket.socket(socket.AF_INET,socket.soCK_STREAM)
sock.connect((IP,port))
#if the IP is the internal one (and the port is too) then it works just fine
#if the IP and port are the external ones set up through port forwarding it says that connection Failed
那么,为什么端口转发不适用于我的代码?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)