Answer the question
In order to leave comments, you need to log in
How to connect 2 computers connected to the Internet: on one run one instance of my program, on the other - the other, and so that the instances communicate via TCP?
Having previously worked only with HTTP (a rather high-level and simple protocol), now I am slowly descending deeper, to the level of TCP and rarer protocols based on it.
I'm mainly interested in sniffing and creating bots that imitate clients for existing servers (usually TCP is used by NodeJS servers, there are also XMPP and other fast messaging protocols where TCP + TLS encryption)
But at the same time I decided to deal with the direct purpose of TCP / IP, then there is a direct connection of two computers without a third-party HTTP server (which is the simplest and most stupid solution to such a problem).
So.
I wrote 2 test programs using System.Net.Sockets, one is a server, the other is a client.
The client sends a test packet to the server, the server, upon receiving it, sends a response packet to the client, this is not the point. IP and port are set by the user both at the server and at the client.
Everything works on localhost.
But now I have 2 computers with Windows 8/8.1 (not Server), and it is necessary that the client be on one of them, and the server on the other.
What needs to be done for this?
1) On what IP to start the server, to what IP to connect from the client? What about ports?
2) What where to set up?
3) In general, of course, I would like the computers to not be physically connected in any way, only via the Internet. Moreover, they are not necessarily connected to one point.
Is this possible?
But, if necessary, you can create your own Wi-Fi point / network, you can also connect it with a cable.
What exactly is needed from this?
As for Google, I ask you not to write.
I know how to google, and in parallel with waiting for answers to my question, I will google.
But this is not an easy task, and I do it better than many others. But now I'm in a shitty mood, and to be honest, I don't feel like doing anything at all. But you must.
UPD: Damn-how- everything- difficult - reluctance. Burn it all with fire, I'll take http
Answer the question
In order to leave comments, you need to log in
1) On what IP to start the server, to what IP to connect from the client? What about ports?
2) What where to set up?
3) In general, of course, I would like the computers to not be physically connected in any way, only via the Internet. Moreover, they are not necessarily connected to one point.
as an example, the server you have is on ip 192.168.0.101 broadcasts and listens on port 1000, the client is on a PC with ip 192.168.0.102 there is a client that listens and receives packets on port 1000. read about client-server applications
You must have a public IP on the server. To obtain it, contact your provider.
Further, if your computer is on the local network (behind a router or server), then through NAT you need to forward the port from the server / router to the computer where the server part of the application is installed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question