How to make connection between two different networks.

Basically, i have my code for connecting server-client on local network, but how do i make them to connect over different networks? I using udp btw.
UDP is connectionless, so they won't connect. Connecting over different networks is just the same as connecting in a LAN. Give it an IP address to connect to and you're set.
Okay, so do I get my actual PC's address then? So could somebody else connect.

Atm, I am using
1
2
3
4
   myIP.b1 =  ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b1;
    myIP.b2 = ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b2;
    myIP.b3 = ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b3;
    myIP.b4 = ((struct in_addr *)(host->h_addr))->S_un.S_un_b.s_b4;


But that obviously wont get me what I want. Its gonna be like 192.168.1.xxx.

One way to get my address is go through google "Whats my ip", but is there another more approprate way to do it?

It's not an application issue, nor a TCP/UDP issue. It's an IP routing/naming issue.

If you're on an internal home network and you want to connect to another computer on a different internal home network ... well, that's the problem.

Don't go off changing your application or protocol. By and large, if an app works on a local machine and is well behaved, it should work anywhere. That's the power of IP.

Well behaved includes:
- using configurable addresses
- using send/recv in loops to send/receive all data in the buffer

http://v2.cplusplus.com/forum/general/63199/#msg342030
Last edited on
Topic archived. No new replies allowed.