Yes, router will make it more complicated.
What you will need is called "port fowarding" - setting on router where you can specify that all incoming connections on port A must be forwarded to your computer on internal network on port B (can be same number as port A).
This way if somebody connects to your public IP address (what router has) on port A, then router will make sure to connect it to internal computer on port B.
But your program won't need any changes. All you need it updating this router setting on side which will be listening ("server") and your program should be able to connect.
There are more advanced techniques, like NAT hole punching, but it is not guaranteed to work (depends on your ISP and router). There is also UPNP protocol that allows server application to ask router to forward port automatically, but that is huge security risk - in any decent network environment it should be turned off.
Other than that hosting a 3rd party relay server outside of both of your home networks is another solution. This way traffic will always go through accessible server on network, regardless of router configuration.