TCP/IP通信全球网 [英] TCP/IP communication global net

查看:63
本文介绍了TCP/IP通信全球网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我对tcp/ip有疑问.
我阅读了一些有关此主题的教程,并做了一些项目可以在我的家中本地局域网内进行通信,但是我无法弄清楚,也找不到在本地进行通信所需要做的任何事情.网.例如,我在葡萄牙,我想用c ++制作一个应用程序以共享文件或与我在巴西的一个朋友交流.

我的猜测是我需要我的全局IP,但是我如何获得它呢?我只获得本地IP.

在此先感谢
Filipe

Hi,

I have one doubts about tcp/ip.
I read a few tutorials about this subject and I made some projects to communicate inside my local net, at my home, but I can''t figure out and I can''t find anywhere what I must to do to communicate outside my local net. For instance, I am in Portugal and I want to make a app in c++ to share files or communicate with a friend of mine which is in Brazil.

My guess is that I need my global ip, but how can i get it? I only get the local ip.

Thanks in advance
Filipe

推荐答案

这不是C ++问题...

您需要做的是配置路由器或调制解调器以进行端口转发.

这将告诉它将去往特定端口,您指定的IP或计算机的所有流量路由.

默认行为是丢弃所有未请求的数据包.
This is not a C++ question...

What you need to do is configure your router or modem to do port forwarding.

This will tell it to route any traffic going to a specific port, to an IP or machine that you specify.

The default behavior is to just drop any packets that were not requested.


这是一个很好的基本问题,通常会被误解.

如果您是客户端并启动连接,则您自己不需要全局IP地址.但是,您需要知道对方(服务器)的唯一,可路由的全局IP地址.例如,如果您在巴西的朋友是一台服务器,并且具有全球IP,则可以从可能具有私有IP地址范围(例如10.xxx,192.168.xx等)的家用计算机发起与其计算机的连接.上).

一旦建立了TCP/IP连接,就可以双向通信.

通常,并非总是可以采用另一种方法(在专用IP地址上的服务器),除非您开始乱用路由器设置,例如通过NAT和NAPT映射端口,或者如果使用动态DNS.如果您正在学习TCP/IP,请不要担心它,直到您掌握基础知识为止.

尝试了解源和目标TCP端口的概念,以及如何通过四个参数(2xTCP端口号,2xIP地址)唯一确定连接.

希望对您有所帮助.
This is a good basic question, which is often misunderstood.

If you are a client, and initiating a connection, you do not need a global IP address yourself. However, you need to know the other party''s (server''s)unique, routable, global IP address. For example, if your friend in Brazil is a server, and has a global IP, you can initiate a connection to his computer from your home computer which may have a private IP address range (such as 10.x.x.x, 192.168.x.x and so on).

Once a TCP/IP connection has established, you can communicate both ways.

The other way around (server on a private IP address) is generally, not always possible, unless you start mucking around with router settings such as mapping ports through NAT and NAPT, or if you use dynamic DNS. If you are learning about TCP/IP, do not worry about it until you get the basics.

Try to understand the concept of source and destination TCP ports, and how a connection is uniquely determined by four parameters (2xTCP port numbers, 2xIP addresses).

Hope this helps.


您所描述的是您的计算机托管服务器的情况,您需要知道您的公共IP地址,以便可以将其提供给客户端,从而允许客户端进行连接给你.

很难从任何一台计算机确定公用IP地址.例如,可能存在一种情况,即本地网络上的许多计算机都共享从单个调制解调器/路由器公开的同一公共IP地址.

在某些系统中,可以使用路由器发现公用IP地址,该路由器可以使用UPnP通知计算机公用IP地址.

但是,最简单的解决方案是让计算机访问提供网站响应的公共IP地址的许多网站之一.这样的网站之一是www.WhatIsMyIP.com.解析响应.

另一个解决方案是DNS或动态DNS(DDNS),您可以在其中向DNS服务器注册计算机.对于DDNS,计算机还必须运行一个小型应用程序,以将其IP地址告知DDNS服务器. DNS(或DDNS)的最大优点是,您的客户端可以使用ASCII文本字符串(例如microsoft.com)找到您,该字符串会被DNS服务器映射到您的实际公共IP地址. DDNS提供程序的一个示例(免费)是www.no-ip.com.

迈克
You are describing a situation where your computer is hosting a server, and you need to know your public IP address so that you can give it to clients thereby allowing clients to connect to you.

The public IP address is difficult to determine from any single computer. There might be a situation, for example, where many computers on a local network all share the same public IP address that''s exposed from a single modem/router.

In some systems, it''s possible to discover the public IP address using the router which can inform a computer of the public IP address, using UPnP.

The simplest solution, however, is for the computer to access one of the many web sites that provide the public IP address that the site is responding to. One such site is www.WhatIsMyIP.com. Parse the response.

Another solution is DNS or dynamic DNS (DDNS), where you register your computer with a DNS server. For DDNS, the computer must also run a small application to advise the DDNS server of its IP address. The big advantage of DNS (or DDNS) is that your clients can find you using an ASCII text string (like microsoft.com), which the DNS server maps into your actual public IP address. One example of a DDNS provider (that''s free) is www.no-ip.com.

Mike


这篇关于TCP/IP通信全球网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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