Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > 9825acea20b8c1730a908ceb6b6baa6d > files > 102

fpc-doc-3.0.4-6.mga7.armv7hl.rpm

{
    This file is part of the Free Pascal run time library.
    Copyright (c) 2003 by the Free Pascal development team

    test netdb unit, network 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.

 **********************************************************************}
program testhst;

uses netdb,sockets;

Procedure DumpNetEntry(Const N : TNetworkEntry);

begin
  With N do
    begin
    Writeln('Name     : ',Name);
    Writeln('Addr     : ',HostAddrToStr(Addr));
    Writeln('Aliases  : ',Aliases);
    Writeln;
    end;
end;

Procedure TestAddr(Addr : string);

Var
  N : TNetworkEntry;

begin
  If GetNetworkByAddr(StrToHostAddr(Addr),N) then
    DumpNetEntry(N)
  else
    Writeln('No entry for address ',Addr)
end;

Procedure TestName(Const Net : string);

Var
  N : TNetworkEntry;

begin
  If GetNetworkByName(Net,N) then
    DumpNetEntry(N)
  else
    Writeln('No entry for netname ',Net)
end;

begin
  testaddr('127.0.0.0');
  testname('loopback');
end.