Router connection issues

Alright guys, I’m new here, so don’t take to me too harshly.

I’ve got the fundamentals of java down, so I’m tackeling my first real java program - a direct two-way chat program. This involves networking, sockets, etc… which I don’t consider the fundamentals.

The program works great on my home lan, but if I set up the server and try to connect outside the network, nothing happens. I’m assuming this is because the router is throwing things off. How can I take this into account when writing a simple client-server program?

If you need source code, i’ve got four short classes, so just ask me and I’ll post 'em.

It’s a tricky problem. You can set up the router to forward all packets comming in on a certain port too the computer running the server. But having a server inside a nat is usually something to avoid. It is difficult enough to run the client from behind a router/NAT (they work the same way, right?). Atleast then you can use nat punch through aka solisited udp. Then you don’t have to mess with the router. But is trycky to code.

I looked into something called Port Forwarding, it seems to work. I’m not exactly sure what a NAT is though. Thanks for the lead!