Good day!

I need to write a program that implements a direct global connection between two computers. I found and worked quite a lot of articles and code on the Internet, and for a start I stopped at the implementation, like here http://www.quizful.net/post/java-socket-programming . It works perfectly on lockalhost and if you set your target IP as your own, programmatically obtained like this - http://cloud-notes.blogspot.ru/2012/05/java-ip.html , but only if it is local, and the connection between two different computers, or their own, but no longer passes through the global IP. Suspicions of NAT have fallen - but between two computers isolated from each other with direct access to the Internet, (as determined by this https://ru.wikibooks.org/wiki/Network_port/What_Single_NAT_and_how_determine , _find_li_my_for_NAT articles) also failed. The proxy is not used, (looked here http://www.lagado.com/proxy-test ) the firewall is disabled on both machines. Tested many times, and in the global network, and in the local (router), but without success. I read somewhere that most of the providers give out dynamic IPs, which is why they do not connect using pre-specified ones, but this does not solve the problem by which computers on the local network do not connect. Revised all previous questions on (oddly enough) StackOverflow, but did not find a specific solution, despite several identical problems.
I would be very grateful if: (any of the following)
- Prompt the possible causes and their circumvention ( absolutely all assumptions are suitable)
- They will give a code / link to a code with a ready-made implementation that takes into account this problem.
- Prompt alternative mechanism of simple direct connection between two remote / local computers by Java

Used: Java 1.8.0_101 under the platform of Windows 7, and the Yota modem, either directly or through Asus router. Firewall and antivirus are disabled during testing.

    1 answer 1

    The reason is to find a computer on the network using an IP address. However, in the case of NAT, you don’t have your own address at all, and in the case of dynamic, you don’t have a permanent one. There are three options:

    1. Buy ip address. At least one. Then one computer will be a server, the other will be a client.

    2. Read about P2P networks. Here, of course, you still need a dedicated server to connect. However, it will be possible to find free hosting and write everything on php.

    3. Read about DynDNS. In the case of a dynamic ip, you can raise the server. But I didn’t work with this, so Google will help you) Or a more specific question on SO, depending on what you choose.

    UPD Did not notice about local networks. First make sure that the IP addresses are correct. Type ipconfig in the console and make sure that the client actually contains the server address, and the server the client address. Although to be honest, I still did not understand from your text whether or not your local network connection through local addresses worked or not.