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.
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