123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- {
- $Id$
- This file is part of the Free Pascal run time library.
- Copyright (c) 2003 by the Free Pascal development team
- test netdb unit, host part
-
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- {$mode objfpc}
- {$h+}
- program testdns;
- uses netdb;
- Procedure DumpHostEntry(Const H : THostEntry);
- begin
- With H do
- begin
- Writeln('Name : ',Name);
- Writeln('Addr : ',HostAddrToStr(Addr));
- Writeln('Aliases : ',Aliases);
- Writeln;
- end;
- end;
- Procedure TestAddr(Addr : string);
- Var
- H : THostEntry;
- begin
- If ResolveHostByAddr(StrToHostAddr(Addr),H) then
- DumpHostEntry(H)
- else
- Writeln('No entry for address ',Addr)
- end;
- Procedure TestName(Const N : string);
- Var
- H : THostEntry;
- begin
- If ResolveHostByName(N,H) then
- DumpHostEntry(H)
- else
- Writeln('No entry for hostname ',N)
- end;
- Var
- I,l : INteger;
- Ans : Array [1..10] of THostAddr;
- H : THostAddr;
- NAns : Array[1..10] of String;
- begin
- Writeln('Resolving name ');
- l:=ResolveName('malpertuus.wisa.be',Ans);
- Writeln('Got : ',l,' answers');
- For I:=1 to l do
- Writeln(i:2,': ',hostAddrtostr(Ans[i]));
- Writeln('Resolving address ');
- H:=StrtoHostAddr('212.224.143.202');
- L:=ResolveAddress(H,NAns);
- Writeln('Got : ',l,' answers');
- For I:=1 to l do
- Writeln(i:2,': ',NAns[i]);
- Writeln('ResolveHostByName:');
- testname('malpertuus.wisa.be');
- Writeln('ResolveHostByAddr:');
- testaddr('212.224.143.202');
- end.
- {
- $Log$
- Revision 1.2 2003-05-17 20:54:03 michael
- + uriparser unit added. Header/Footer blocks added
- }
|