Hi,
to retrieve the public ip address, the website
www.whatismyip.org is queried. Unfortunately, sometimes (seldomly, but it happens) this site is down, so it may be useful to check another site, too?
There is
http://checkip.dyndns.org which sends back a strings like
<html><head><title>Current IP Check</title></head><body>Current IP Address: 84.58.110.116</body></html>
which is a little more work to parse than the other one but I think it's worth.
edit: Oh, and one could work with the new Http-classes here.