forsnow's method is not always correct: If I'm using local net and
MODEM, then my local IP is always not 0.
As for Wang hansong's method 2, you can use:
gethostname, then
gethostbyname, and analyze the return value,
if you found new IP addr comes into your HOST struct,
then it shows you are connected onto the Internet.