Possible Duplicate:
Discovering public IP programatically
Is there a way to know my public IP address from a C program? I am using a DSL modem and working on Linux operating system.
I need to know the public IP, so that I can make the server-client socket program work while on Internet.
Yes, you can use the STUN protocol to ask a STUN server what IP address it sees your request originating from. There are several open STUN servers you could use, stunserver.org for example.