A
A
aarifkhamdi2017-08-10 11:33:38
Python
aarifkhamdi, 2017-08-10 11:33:38

How to make a direct connection (NAT's)?

I study network programming. I'm not kidding at all. Explain in more detail, please.
Actually, the question is in the title.
Connecting to the server doesn't seem to be a problem. Finding a client behind NAT is his problem.
But in a situation where both clients behind NAT'om what to do? How to get their addresses? Where to knock to establish a connection?
In general, there was a feeling that sockets are too low-level tool for network communication. Is this true? Or I just don't know what to google... If it's true, please advise relevant c++, python libraries.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Maxim Grishin, 2017-08-10
@vesper-bot

Read towards STUN in this case. You need a peer with a white address that performs the work of the organizer for such a connection. Otherwise, no way.
As for sockets - no, that's it. And it is for this purpose that they ask for a white IP address for the server, if they don’t give it, you can ask to organize port forwarding through NAT from some address (say, a request for 1.2.3.4:9999 on router 1.2.3.4 is sent to 172.16.3.4: 12345, where the server is already standing and listening on the port).

D
Derevyanko Alexander, 2017-08-10
@dio4

Do so. On that server, WHERE you need it, select a separate port (for example, 7777) and send your packets to it. And there, on the server, ask the admin to redirect incoming to this port to the REGULAR ports of machines from the LAN (for example, to 80). That's all. Those you send (we suppose) your TCP to port 7777, and the server forwards them to local cars on the 80th regular port. And if someone's httpd plows there, then he will answer you and you will receive his response.
Just as an example for RDP and Radmin on FreeBSD
here
And I'm sorry, maybe before you try to raise network programming (IMHO it's not easy), first just figure it out with networks? Although it's none of my business.

L
Leonid, 2020-09-17
@sled

1. Get an external IP address and port for PC1 and PC2
2. Through a common social network account (VK), exchange IP addresses and ports

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question