What IP adress should be used to connect to server running on my pc from other machines? In my server, I call zmq_bind to listen for all incoming connections, like this:

zmq_bind(socket, "tcp://*:12781");

In my client, I try to connect to the server by:

string IP = "127.0.0.1";    //what should be here?
string connection_string = "tcp://" + IP + ":12781";
zmq_connect(socket, connection_string);

My program works already when the server and client are running on the same computer(IP is 'localhost', '127.0.0.1' or '192.168.1.13'). What IP should I use when connecting from other computers? I already tried my IPV4 which I found here, it didn't work.
Thanks for help.

New contributor
Matezzzz is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 2
    This depends on your networking setup. For example if your external IP (the one you linked to) is behind a router you may need to configure your router to open that port and redirect traffic to your internal IP. Can you describe your exact setup in more detail? – Galik yesterday
  • "What IP adress should be used to connect to server" - well, the actual IP of the server, obviously. Every machine has a unique IP on your network (unless it was set up by morons) and the unique IP of the server is what you should use. However, if whomever set up the network was a little bit more clever, then they would have ensured that the machines did not just have IP addresses, but DNS names, so that instead of a numerical address you could use something more human readable like "server.my-lan.local" (or whatever). – Jesper Juhl yesterday
  • How can I configure my router to do this? My router is from Netgear and I am using windows 10. – Matezzzz yesterday
  • @JesperJuhl How can I get the actual IP of the server? – Matezzzz yesterday
  • 1) log onto the machine and look up its networking configuration. 2) know its DNS name and query your local DNS server (assuming there is one). – Jesper Juhl yesterday

Your Answer

Matezzzz is a new contributor. Be nice, and check out our Code of Conduct.
 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.