Forum > General

Get public IP adress

(1/3) > >>

Jake012345:
Hello!  (Sorry if I didn't found it, but answerd in other topic %))

How can I get and use public IP?
(I can find it with browser but i want to use in a program)
And
I heard that the TCP/IP connection working with public IP adress without any help.
Really?

Thanks for answers!

GetMem:
@Jake012345

--- Quote ---How can I get and use public IP?
--- End quote ---
Try this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses fphttpclient; function GetURL(URL: String; var URLRes: String): Boolean;var  SS: TStringStream;  FPHTTPClient: TFPHTTPClient;begin  Result := False;  FPHTTPClient := TFPHTTPClient.Create(nil);  try    FPHTTPClient.AllowRedirect := True;    SS := TStringStream.Create('');    try      Screen.Cursor := crHourglass;      try        FPHTTPClient.Get(URL, SS);      finally        Screen.Cursor := crDefault;      end;      if FPHTTPClient.ResponseStatusCode = 200 then      begin        URLRes := SS.DataString;        Result := True;      end;    finally      SS.Free;    end;  finally    FPHTTPClient.Free;  end;end; procedure TForm1.Button1Click(Sender: TObject);var  Str: String;begin  if GetURL('http://bot.whatismyipaddress.com/', Str) then    ShowMessage('My public IP is: ' + Str);end;

Jake012345:
Thank You!

Thaddy:
or ip.thaddy.com which is much older....
And more reliable...
Thing is you need a real connection to show what your real external IP is.
I also host a different one that is slightly nore advanced. (resolves proxies)

Remy Lebeau:
Typically, querying a public website for the IP that connects to it works fine, and does report YOUR IP that is connected to the external world.  This is the approach I usually recommend, same as other users.

However, it has recently come to my attention that some ISPs hide their users behind a NAT on the ISP's side, in which case such sites will see the ISP's IP, not the user's IP.  So, to get your own external IP (ie, the IP that is connected to the ISP) in that situation, you would have to query your modem/router directly instead, such as with uPNP.

Navigation

[0] Message Index

[#] Next page

Go to full version