So then, if someone wants to contact you across the internet then they need to specify your public IP address and a port number. You will have to have forwarded that port number to your computer on your router. Obviously you must set up port forwarding first, then tell the clients what port number to use. The code is exactly the same whether you're communicating across your LAN or over the internet: you specify an IP address and a port number. The difference is who receives and interprets those values: the server itself or the router.