路由器后面的客户端服务器程序
我正在尝试运行客户端服务器UDP程序。 我的两台机器位于不同的网络中。 我已经在路由器中设置了端口转发。
我的服务器有两个 IP 地址: 1) 外部 200.?.?.? 2)内部192.168.0.100
在创建UDP服务器时,我需要创建一个绑定到地址的套接字。
我应该将套接字绑定到什么地址,外部还是内部?
我尝试使用内部地址,但它没有从客户端获取任何数据。
建议...
I am trying to run client server UDP program .
My both machines are in different networks. I have set up port forwarding in my router.
My server has two IP Address :
1) External 200.?.?.?
2) Internal 192.168.0.100
While creating UDP server I need to create a socket which is binded to addresss.
What address should I bind socket to, external or internal?
I tried with internal address but it is not getting any data from client.
Suggestions...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
鉴于您说您设置了端口转发,您是否在 UPD 程序中分配了正确的端口? 或者您只是将数据发送到某个 IP 地址? 如果指定外部 IP 地址和端口号,路由器上的端口转发应将其发送到网络上的适当节点。
Given the fact that you said you set up port forwarding, did you assign the proper ports within the UPD program? or are you just sending data to an IP address? If you specify the External IP address and a port number, the port forwarding on your router should send it to the appropriate node on the network.
如果必须绑定到特定地址,那么它将是内部地址,而不是外部地址。
路由器上 NAT 的全部目的是向外界隐藏您的内部网络寻址方案。 路由器的 NAT 算法将负责将任何入站数据包上的目标 IP 地址重写为正确的内部 IP 地址。
它不起作用表明您的端口转发和/或路由器上的防火墙有问题。 除了转发规则之外,您还需要设置特定的防火墙规则来允许流量,这种情况并不罕见。
If you must bind to a specific address, then it would be the internal address and definitely not the external address.
The whole point of the NAT on your router is to hide your internal network addressing scheme from the outside world. The router's NAT algorithm will take care of re-writing the destination IP address on any inbound packet to the correct internal IP address.
That it's not working suggests that there's something wrong with your port forwarding and/or firewalling on the router. It's not uncommon that you'd need to set up a specific firewall rule to permit the traffic in addition to the forwarding rule.
容易。 如果您有 2 个 IP 地址。 两者都尝试一次。 你会找到一个。
。
使用这个逻辑。 只有两个ip。 找到合适的、有效的。
。
Easy may. In case you have 2 ip address. Try both once to other. You will find one.
.
Use this logic. Only two ip. Find the right one which will works.
.