WinSock 客户端端口和路由器端口转发
我有一个绑定到端口并侦听它的服务器应用程序。我已设置路由器将此端口上的数据转发到服务器。
现在,在客户端,我实际上并没有将套接字绑定()到任何端口,并且通常每次都会得到不同的端口。在这种情况下,我该如何准备路由器将该端口转发给客户端?或者我是否也应该对客户端套接字使用bind()? (我记得读到过你不应该这样做。)
I have a server application that binds to a port and listens on it. I've set up the router to forward the data on this port to the server.
Now, on the client side, I don't actually bind() the socket to any port, and I usually end up with a different port everytime. In that case, how can I prepare the router to forward that port to the client? Or am I supposed to use bind() with the client socket as well? (I remember reading that you're not supposed to do that.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
防火墙通常是有状态的 - 这意味着如果允许进入受保护网络的 TCP 连接请求,则返回客户端的数据包将自动匹配(并通过)。也就是说,您不必担心客户端,只需设置端口转发到服务器应用程序即可。
Firewalls are usually stateful - meaning if TCP connection request into the protected network is allowed, then the packets back to the client are matched (and passed through) automatically. That is to say you don't worry about the client, just setup port forwarding to the server app.