
uses
  Crt,
  CoDefs,
  CoBase,
  CoIpV4,
  CoEth01,
  CoINET,
  CoUDP,
  NumToStr;



procedure OpenCloseTest;
var
  Status : TCoStatus;
  Sock   : PCoDevice;
begin
  Status := NetOpenSocket( 'UDP', 'LPORT=5000', '', Sock );


  if Status <> CST_SUCCESS then
  begin
    WriteLn( 'NetOpenSocket() failed: ', CoStatusToStr( Status ) );
  end;

  Status := Sock^.CoBind( nil, COF_PROPAGATE, nil );

  if Status <> CST_SUCCESS then
  begin
    WriteLn( 'CoBind() failed: ', Sock^.CoStatusToStr( Status ) );
    CoReleaseDevicePtr( Sock );
    Exit;
  end;

  Status := Sock^.CoUnbind( 0, nil );

  if Status <> CST_SUCCESS then
  begin
    WriteLn( 'CoUnbind() failed: ', Sock^.CoStatusToStr( Status ) );
  end;

  NetCloseSocket( Sock );

end;

var
  Status: TCoStatus;
  Counter: Integer;

begin

  WriteLn( 'MemAvail: ', MemAvail );

  WriteLn( 'Press any key' );
  ReadKey;

  { Otevreni TCP/IP stacku }

  Status := NetOpenStack( 'ETH01', 'IOBASE=$300',
             'IPADDR="192.168.1.210" REASMTO=5', '' );

  Counter := 0;

  repeat

    OpenCloseTest;
    WriteLn(Counter);
    Inc(Counter);

  until Keypressed;

  NetCloseStack( '' );

  { Uzavreni TCP/IP stacku }



  WriteLn( 'MemAvail: ', MemAvail );

end.