Autor Beitrag
Tomok
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Mo 21.04.03 10:19 
Ich nutze zur Zeit die GameNet.pas Unit (www.zoksoftware.de/).
Ich habe folgende 2 Fragen :
1.Eignet sich die Unit auch für Spiele über's Internet ?
2.Wie finde ich heraus, welche IP ich im Internet habe ?
Moritz M.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Mo 21.04.03 10:28 
Tomok Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Mo 21.04.03 10:44 
Danke für den Tip, nur läuft das eine Beispiel bei mir nicht, weil ich einige der
Komponenten nicht habe und das andere ermittelt scheinbar nur lokale IPs.
Tomok Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Mo 21.04.03 12:09 
Ich hab es geschaft !!!!!!!!!!!!!! :D Hier ist meine Unit
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
unit IPGet;

interface

uses
  URLMon,Sysutils;

function getIP : String;

implementation

const
  IPPage = 'http://www.whatismyip.com/';
  TMPFile = 'C:\MyIP.htm';

function getIP : String;
var
  f     : Textfile;
  s1,s2 : string;
  b     : Boolean;
  i,x,y : integer;
begin
  URLDownLoadToFile(nil,IPPage,TMPFILE,0,nil);
  assignfile(f,TMPFile);
  reset(f);
  s2 := '';
  while not eof(f) do
    begin
      readln(f,s1);
      s2 := s2+s1;
    end;
  s2 := uppercase(s2);
  b  := false;
  i  := 0;
  repeat
    if (s2[i]='I')and(s2[i+1]='S'then
      begin
        x := i;
        repeat
          inc(x);
        until ((s2[x]='1')or(s2[x]='2')or(s2[x]='3')or(s2[x]='4')or(s2[x]='5')
             or(s2[x]='6')or(s2[x]='7')or(s2[x]='8')or(s2[x]='9')or(s2[x]='0'))
             or (x>=length(s2));
        y := x;
        repeat
          inc(x);
        until (not((s2[x]='1')or(s2[x]='2')or(s2[x]='3')or(s2[x]='4')or(s2[x]='5')
             or(s2[x]='6')or(s2[x]='7')or(s2[x]='8')or(s2[x]='9')or(s2[x]='0')
             or (s2[x]='.')
             or (x>=length(s2))));
        result := (copy(s2,y,x-y));
        b := true;
      end;
    inc(i);
  until b or (i>= length(s2));
  closefile(f);
  deletefile(TMPFile);
end;

end.


Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt
Moritz M.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Mo 21.04.03 12:12 
Ja, du hast die Web-gestützte Methode benützt.
FloSch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 129



BeitragVerfasst: Mo 21.04.03 12:39 
Hallo,

der Source oben von Tomok ist ja ein Hammer :lol: Extrem
umständlich oder?

Habe eben auch einen mal gebastelt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
const
  sURL = 'http://www.whatismyip.com';
  sSearchText = 'your ip is';
var
  sResult: string;
  sIP    : string;
begin
  try
    sResult := http.Get(sURL);
    sResult := LowerCase(sResult);
    sIP := Copy(sResult, pos(sSearchText, sResult) + Length(sSearchText) + 1,pos(' ', Copy(sResult, pos(sSearchText, sResult) + Length(sSearchText) + 1, length(sResult))) -1 );
    ShowMessage(sIP); // hier nun deine ip...
  except
    MessageDlg('Sie sind nicht mit dem Internet verbunden.', mtError, [mbOK], 0);
  end;


Mein Source nutzt die TidHTTP Komponente von Indy.

Grüße
Florian :roll:

Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt
Starfighter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Mo 21.04.03 12:56 
hallo,

wo ist den die Indy Komponente?
FloSch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 129



BeitragVerfasst: Mo 21.04.03 13:07 
Hallo,

die Indy-Komponenten gibt es unter
nevrona.com/indy

Grüße
Florian :roll:
BeniSchindler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 82

Win 2k / suse9.1
D7 Prof / Kylix 3
BeitragVerfasst: Di 22.04.03 18:11 
@FloSch:

thx,thx,thx!!!

gute und schnelle lösung.

Alle anderen Lösungen die ich bisher hatte, waren umständlich und haben entweder in Windows oder in Linux nicht richtig funktioniert. Dank dieser Lösung und dank dieser Web-Site muss ich mich jetzt um ein Problem weniger kümmern. Ich weiss nicht wer auf die Idee kommt eine Website zu machen, auf der man nur seine IP sieht, es ist jedoch verdammt gut :)

Nach einem Jahr Delphiforumspause 5 min online und schon wieder ein Problem weniger.

mfg Beni.
FloSch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 129



BeitragVerfasst: Di 22.04.03 18:28 
Hallo,

kein Problem :lol:

Grüße
Florian :roll:

_________________
Windows 200 Prof. - Debian Sarge
D5 Prof & D6 PE - Kylix 3 Professional - Free Pascal
Danny W.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 296

Windows XP, WIN 2000
Delphi 2005 PE
BeitragVerfasst: Mi 15.11.06 14:11 
Funktioniert leider nichtmehr..die haben wohl die Seite geändert :(

_________________
"Ich find den Fehler nicht. Der Artist wird immer als "Syntax Error" gezeigt :("
"Ach verdammt, der Artist heißt wirklich "Syntax Error" xD"
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 15.11.06 14:50 
Moin!

Zieh dir mit TIdHttp die Seite von www.whatismyip.com oder checkip.dyndns.org und filter doch einfach die Adresse raus, ist ja keine Kunst. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Danny W.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 296

Windows XP, WIN 2000
Delphi 2005 PE
BeitragVerfasst: Mi 15.11.06 14:52 
stimmt..das mach ich eben :)

_________________
"Ich find den Fehler nicht. Der Artist wird immer als "Syntax Error" gezeigt :("
"Ach verdammt, der Artist heißt wirklich "Syntax Error" xD"
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mi 15.11.06 15:01 
Deine effektive IP im Internet ist vielleicht gar nicht so relevant. Wenn du nämlich hinter einem NAT bist, dann ist es häufig nicht deine eigene IP sondern eine Sammel-IP (die bringt dir zum Gamen nicht viel). Du solltest die IPs des Rechners direkt bestimmen. Dafür brauchst du auch gar keine externe Seite. Die Info aus ipconfig würde reichen. Natürlich kann man die IPs auch programmatisch bestimmen (ohne ipconfig). Falls der Rechner in einem lokalen Netz ist, kriegst du so die lokale IP raus und du kannst übers lokale Netz spielen. Bist du direkt am Internet angeschlossen, so solltest du auch die direkte IP im Internet erhalten. Mehr macht selten Sinn.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 15.11.06 15:16 
Moin!

Hier mal ein Ansatz:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
uses
  ..., RegExpr, IdHttp;

procedure TForm1.Button1Click(Sender: TObject);
  var
    RE: TRegExpr;
    IdHTTP: TIdHTTP;
begin
  RE := TRegExpr.Create;
  IdHttp := TIdHTTP.Create(NIL);
  try
    try
      RE.Expression := '(\d{1,3}\.){3}\d{1,3}';
      if RE.Exec(IdHTTP.Get('http://www.whatismyip.com')) then
        Edit1.Text := RE.Match[0]
      else
        Edit1.Text := 'Fehler: IP nicht vorhanden!';
    except
      Edit1.Text := 'Fehler: '+Exception(ExceptObject).Message;
    end;
  finally
    IdHTTP.Free;
    RE.Free;
  end;
end;

Aber Vorsicht:
a) Benötigt Indy und TRegExpr,
b) prüft die IP nicht auf Gültigkeit,
c) ist so nicht Proxy-tauglich (muss separat konfiguriert werden),
d) liefert dann aber ggfs. den Proxy, und nicht die eigene IP!

Ansonsten sind die Hinweise von user profile icondelfiphan natürlich noch zu beachten. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Manina
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44

Win 7 Pro
RAD Studio 2010 Pro
BeitragVerfasst: Mo 23.03.09 22:22 
Es geht auch noch einfacher: :wink:

ausblenden Delphi-Quelltext
1:
2:
3:
var CurrIP : String;
...
    CurrIP := IdHTTP.Get('http://www.whatismyip.com/automation/n09230945.asp');


Das liefert genau die nach außen sichtbare IP, ohne den ganzen Text drumherum... :wave:

_________________
Gates, oder Gates nicht ?
Dude566
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Mo 23.03.09 22:29 
Vielleicht hilft das ja weiter: KLICK MICH

_________________
Es gibt 10 Gruppen von Menschen: diejenigen, die das Binärsystem verstehen, und die anderen.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 23.03.09 22:37 
Moin!

user profile iconDude566 hat folgendes geschrieben Zum zitierten Posting springen:
Vielleicht hilft das ja weiter: KLICK MICH
Du bist im falschen Film, hier geht´s um die öffentliche IP (dein Link ermittelt die lokale IP)! ;)


user profile iconManina hat folgendes geschrieben Zum zitierten Posting springen:
Es geht auch noch einfacher:
Wenn dieser Dienst zur Verfügung steht. Ansonsten ist eine flexiblere Lösung wohl der bessere Ansatz. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Dude566
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1592
Erhaltene Danke: 79

W8, W7 (Chrome, FF, IE)
Delphi XE2 Pro, Eclipse Juno, VS2012
BeitragVerfasst: Mo 23.03.09 22:40 
Oh, habe die Posts nur schnell überflogen und dort fiel auch einmal das Wort Lokal.

_________________
Es gibt 10 Gruppen von Menschen: diejenigen, die das Binärsystem verstehen, und die anderen.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 23.03.09 22:41 
*räusper* Das Datum des ersten Postings ist euch schon aufgefallen? ;-)

_________________
We are, we were and will not be.