使用来自不同局域网的NAT服务器和客户端的聊天程序 [英] Chat program using NAT server and client from different lan network

查看:130
本文介绍了使用来自不同局域网的NAT服务器和客户端的聊天程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TCP / IP套接字处理图表信使。如果服务器在公共IP上,则程序可以正常工作。如果Serer位于转子后面或者服务器是NAT,程序将失败。如果您可以为我提供服务器为NAT并且客户端从LAN网络连接到不同网络上的NAT服务器的示例,将会很有帮助。



Hi,
I am working on a chart messenger using TCP/IP Socket. The Program works fine if the server is on the public IP.  The program fails if the Serer is behind a roter or if the server is NAT. It would be helpful is you can provide me a sample where the server is NAT and the client is connecting from a lan network to the NAT server on different network.

 


推荐答案

所有NAT都是从集中点(路由器)更改IP地址...

如果你能看到地址公共然后移动使它们私有,但数据包不会向公众发布。问题出在路由器之后的段中......这将在下面的第2节中。除非您必须将出站数据包指向PROXY服务器,否则您的客户端代码没有任何问题。对我来说虽然最好的方法是只通过路由器发送数据包,然后让路由器的人做他们的工作。


私有网络中的客户端---- 1 -----路由器/ NAT --- 2 ----- Public

为了使它能够工作,它们必须在路由器上代理arping。这告诉公共网络什么路由器服务于"物理"网络。 nic卡(客户的实际物理卡)。

您可以运行wireshark跟踪并轻松证明:1)如果客户端发送您期望的数据包(这是路由器问题)
2)如果您从未看到入站公共请求(这是一个路由器的问题)。
3)如果你看到了inbounds但是无法在另一边看到outbounds(这是路由器问题的90%)

如果你的网络伙伴告诉你他们已经设置了代理服务器,那么你必须在套接字本身中使用它。 http://social.msdn.microsoft.com/Search/en-US/?Refinement=112&query=Proxy+meta:Search.MSForums.ForumID(9a657749-56cc-4c35-AF80-b514c8693c79 )但是,请记住,大多数代理服务器都是为HTTP设置的,并提供缓存和其他安全问题。这可能是一个代理问题。

All NAT does is change IP address from a centralized point (router)...

So if you can see the addresses public and then move to make them private but the packets don't make it out to the public.  The problem is in the segment after the router....  This would be in section 2 below.  There is nothing wrong with your client code, unless you must point to outbound packets to a PROXY server.  To me though the best way is to just send the packets out via the router and let the router guys do their work.


client in private network ----1-----Router/NAT---2-----Public

In order for this to work however, their must be proxy arping in place at the router.  This tells the public network what router serves the "physical" nic card (the actual physical card of the client). 

You can run a wireshark trace and prove easily this:
1) If the client is sending out the packets you expect (it is a router problem)
2) If you never see inbound public requests (it is a router problem).
3) If you see inbounds but can't get outbounds to be seen on the other side (it is a router problem 90%)

If your network guys tell you that they have set up a proxy server, then you must use that in the socket itself. http://social.msdn.microsoft.com/Search/en-US/?Refinement=112&query=Proxy+meta:Search.MSForums.ForumID(9a657749-56cc-4c35-af80-b514c8693c79)  However, keep in mind that most proxy servers are set up for HTTP and provide caching and other security issues.  Chances are slim this is a proxy issue.


这篇关于使用来自不同局域网的NAT服务器和客户端的聊天程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆