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.