uses
  Crt,
  CoBase,
  CoIPv4,
  CoEth01;


{const
  Intf1Addr : TIpxAddress = (
    Size: SizeOf(TIpxAddress);
    Net:  (Long:0);
    Node: (Bytes:(0, 80, 252, 33, 19, 153));
    Sock: 5000
  );


  Intf2Addr : TIpxAddress = (
    Size: SizeOf(TIpxAddress);
    Net:  (Long:0);
    Node: (Bytes:(0, 80, 252, 33, 19, 154));
    Sock: 5001
  );}

var
  Eth1     : PCoEth01;
  Ip1      : PCoIPv4;

  Address  : TIpDevAddress;

  Status   : TCoStatus;


  Buff1     : array[0..100] of Byte;
  Buff2     : array[0..1535] of Byte;

  RecvLen   : Word;

  Ovlp1     : TOverlapped;
  Ovlp2     : TOverlapped;

  Device    : PCoDevice;

  IoBase    : Word;

  S         : String;

  P         : Pointer;
begin
  ClrScr;


  if CoCreateDevice( 'ETH01', 'ETH_A', '',
       nil, PCoDevice(Eth1) ) <> CST_SUCCESS then
  begin
    WriteLn( 'Nelze vytorit instanci ETH01' );
    Exit;
  end;


  if CoCreateDevice( 'IPV4', 'IP_A', '',
       CoOpenDevice( 'ETH_A' ) , PCoDevice(Ip1) ) <> CST_SUCCESS then
  begin
    WriteLn( 'Nelze vytorit instanci ETH01' );
    Exit;
  end;

{
  IoBase := $310;

  Status := Ip1^.CoSetOption( DEV_CLASS_ETH01, COPT_IOBASE,
       @IoBase, SizeOf( IoBase ), 0, nil );
  if Status <> CST_SUCCESS then
  begin
    WriteLn ('Nelze nastavit iobase' );
    Exit;
  end;}

{  Status := Ipx2^.CoGetOptionString( DEV_CLASS_ETH01, @S, SizeOf(S) - 1, nil);
  if Status <> CST_SUCCESS then
  begin
    WriteLn( 'nelze precist paramstr' );
    Exit;
  end
  else
    WriteLn( S );


  Status := Ipx2^.CoSetOptionString( DEV_CLASS_ETH01, 'IOBASE=$310', nil );
  if Status <> CST_SUCCESS then
  begin
    WriteLn( 'nelze nastavit paramstr' );
  end;}



  Status := Ip1^.CoBind( nil, COF_PROPAGATE, nil  );
  if Status <> CST_SUCCESS then
  begin
    WriteLn( '1_Bind, Error:', Status );
  end;

  Address.Size := SizeOf( Address );
  Address.Node := MakeIpAddr( 192, 168, 1, 8 );
  Address.Protocol := 255; { !! }


  Status := Ip1^.CoSendBufferTo( @Buff1, SizeOf( Buff1 ), 0,
              PCoAddress(@Address), nil );

  Status := Ip1^.CoSendBufferTo( @Buff1, SizeOf( Buff1 ), 0,
              PCoAddress(@Address), nil );


    WriteLn( Status );

  WriteLn( MemAvail );

  repeat
    Ip1^.CoTick;
  until KeyPressed;


  WriteLn( MemAvail );

  Status := Ip1^.CoUnbind( COF_PROPAGATE, nil );
  if Status <> CST_SUCCESS then
  begin
    WriteLn( '1_Unbind, Error:', Status );
  end;


end.