Began to deal with sockets winsocks. I wrote a program that receives and sends to the same computer messages to the local address. So after all at this local address can not connect from another computer. I tried to transfer the global ip address in the bind () function, but it gave an error.

So, how to implement in general so that my computer would have a server, and you could connect to it from different, not local computers?

Closed due to the fact that the essence of the question is not clear to the participants gbg , cheops , aleksandr barakin , sercxjo , zRrr 19 Jun '16 at 0:37 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Is the local address 127.0.0.1? But if you want with absolutely anyone, then you need to have a dedicated IP or at least a port is forwarded. Otherwise, the problem becomes a little non-trivial. - KoVadim
  • The local address can also be understood as 192.168.0.1/19, no dedicated IP is needed for this. - PinkTux
  • one
    Show your non-working code. - gbg

1 answer 1

In the zero queue - you need the book Sneijder Effective TCP / IP Programming

First of all, you need to decide how your computer is connected to the Internet. Rarely what home user can boast of direct IP from the Internet - WHITE IP. White addresses are non- private .

It is easy to learn - go to 2IP.RU or a similar service, and see what it says about your connection.

If you have a white IP, and there is no router between your computer and the Internet - everything is trivial - open a socket and work.

If there is some kind of router, then this router is most likely NAT. Then we need the means to bypass NAT

If you are the owner of the router, you need to configure it - this is called PortForwarding .

If not, it remains to use NAT traversal techniques, such as ICE and STUN.

Also, there is the possibility of IP connections via overlay networks - tor, tox, and so on.

  • one
    To connect from the addresses 192.168.0.1/19 - why do you need a "white ip"? - PinkTux
  • one
    @PinkTux judging by the last paragraph, the author wants access from the global network. - gbg pm
  • Well, for learning and debugging examples, it will fit in perfectly :) Setting up access is another thing, not particularly relevant to the principles of client-server programming at this stage. - PinkTux
  • @PinkTux local network - the second most ideally data transmission medium, after localhost. Practice shows that code written for lokalkhost on the web can work wonders. - gbg
  • one
    I have little understanding of what "code written for locale" is. Are there any other functions in the library? If we are talking about problems that practically do not occur in LAN, then you should not load a person with unnecessary entities ahead of time. He still does not know how to walk, but already he is told about the features of the placement of barriers at a distance of 400 meters ... - PinkTux