开发者

c++ Library for direct pc to pc communication in a Wide area network (WAN)

开发者 https://www.devze.com 2023-03-17 08:08 出处:网络
The idea is to make a connection between two PCs, each one only with internet access to connect to the other. Both PCs can be in the same LAN or not, and or behind routers, the main idea is that the o

The idea is to make a connection between two PCs, each one only with internet access to connect to the other. Both PCs can be in the same LAN or not, and or behind routers, the main idea is that the only thing that is certain is the internet access.

First of all, my question is: this is possible or exist any kind of solution that not include intermediates or route configurations to allow direct communication between two PCs? (remember the idea is to connect directly without external configurations, the only two places that are allowed to be configured are the both PCs that communicate with each other).

Second que开发者_高级运维stion is: if this is possible, then what libraries or what kind of solution do you suggest to accomplish this (a c++ way/library would be appreciated but not mandatory)

Thanks


In general, no, what you're looking to do is no longer possible.

Whilst the internet was originally designed around "end-to-end communication", with a relatively dumb network in between nodes, what's happened is that more and more network devices get in the way.

In particular, NAT devices make it more or less impossible to make direct point-to-point connections between arbitrary devices on the internet.

Hence most systems these days rely on a central device (to which both nodes can connect) which proxies (or relays) packets between those nodes.


If you need to connect two PCs via Internet then you can create VPN "virtual private network" which means the two machines are birtually in the same LAN. You dont need any external configuration. To setup vpn, youtube has many clips to do that based on your platform. Is that what you want?


As Alnitak mentions this is generally not possible because of the presence of NATs. This may change some day with IPv6. People have come up with various ways of dealing with this and this Wikipedia article looks like a good starting point for reading about this. Usually this involves having both sides "punch a hole" through the NAT that then allows further communication to happen and it requires some third party that is routable from both end points.

Another problem is that for many PC's the NAT/firewall device itself will tend to have a dynamiclly assigned IP address hence again the requirement for some central service to "broker" the connection. Most Internet access providers will charge extra for a static IP address which then together with port forwarding can provide your PC with a IP address/port combination that is always routable.

0

精彩评论

暂无评论...
验证码 换一张
取 消