Internet上TCP的任何良好示例[非Intranet] [英] Any Good Example For TCP Over Internet [not intranet]

查看:71
本文介绍了Internet上TCP的任何良好示例[非Intranet]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我是C#初学者.

我正在开发一个tcp程序.
它可以与具有本地ip的本地网络一起使用,但不能与具有公共ip的Internet一起使用.

有C#天才能帮助我吗?

如果可能,请提供一个示例代码,说明如何设置在tcp服务器和客户端中使用的公共ip地址.

Hi Friends,

I am a C# beginner.

I am developing a tcp programme.
It will work with local network with local ip, but it failed to work in internet with public internet ip.

Any C# genius who can help me?

If it is possible, give a sample code for how to set public ip address which is used in tcp server and client.

推荐答案

这是一个常见问题.

如果您的代码通过Intranet可以正常工作,那么问题就在于接收/服务器端的网络路由,这在代码中无法解决.

当连接请求通过Internet发送到服务器时,它到达该网络的公共IP地址,现在,如果接收方的路由器不知道如何处理该请求,即请求是否进入端口X将其路由到计算机B,然后将其丢弃.
您需要做的是对网络路由的一些研究,特别是端口转发/端口触发.
This is a common question.

If your code works over an Intranet it is fine the problem is network routing on the receiving/server side which is not something that can be fixed in code.

When a connection request is sent to a server over the internet it arrives at the public IP address for that network, now if the routers on the receiving side don''t know what to do with the request, i.e. if request comes in on port X route it to computer B, then it will be dropped.
What you need to do is some study on network routing specifically Port Forwarding/Port Triggering.


这篇关于Internet上TCP的任何良好示例[非Intranet]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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