Autor Beitrag
error
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Fr 11.10.02 15:17 
Hi,
ich habe einen Hostname (www.aug.de) und brauch jetzt die IP von www.auq.de als string. Wie mach ich das?

mfg error
O'rallY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: Fr 11.10.02 20:05 
Du kannst den Server anpingen, z.B. mit der Indy Komponente TIdIcmpClient. So erfährst du die IP. Ich glaub sogar das hier im Forum ein Tutorial ist, wie man pingt. Ich glaub aber mit der Fastnet Kompo.

_________________
.oO'rallY
Linux is like a tipi: No gates, no windows and a gnu-eating apache inside...
SpeedyGTD
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 89



BeitragVerfasst: Sa 12.10.02 20:19 
ich hab noch nie was mit den Indy Kompos gemacht, aber so wie ich das mache gehts nett. Also ich hab schonmal Port auf 53 eingestellt, hab nen Host angegeben, und dann ping gesendet, aber das kann nicht funktionieren, das wäre zu einfach :wink:

PS: Da ich keine Ahnung hab was ich für code schreiben soll hab ich erstmal keinen :wink:

_________________
...hab ich vergessen ;)
noeppel
Hält's aus hier
Beiträge: 6



BeitragVerfasst: Do 24.10.02 09:15 
Mit der Windows API kann man das wiefolgt lösen:

ausblenden 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:
uses Winsock;

function LookupName(const Name: string): TInAddr;
var
  HostEnt: PHostEnt;
  InAddr: TInAddr;
begin
  HostEnt := gethostbyname(PChar(Name));
  FillChar(InAddr, SizeOf(InAddr), 0);
  if HostEnt <> nil then
  begin
    with InAddr, HostEnt^ do
    begin
      S_un_b.s_b1 := h_addr^[0];
      S_un_b.s_b2 := h_addr^[1];
      S_un_b.s_b3 := h_addr^[2];
      S_un_b.s_b4 := h_addr^[3];
    end;
  end;
  Result := InAddr;
end;

function GetHostIP(HostName: String): String;
var
  InAddr: TInAddr;
begin
  InAddr := LookupName(HostName);
  with InAddr.S_un_b do
    Result := inttostr(Ord(s_b1))+'.'+inttostr(Ord(s_b2))+'.'+inttostr(Ord(s_b3))+'.'+inttostr(Ord(s_b4));
end;


mfg noeppel