delphi 用API实现套接字断开重连(主要是在客户端检测服务器是否断开)解决方法

delphi 用API实现套接字断开重连(主要是在客户端检测服务器是否断开)
如题,最好有代码,或是详细的实现过程(不要用心跳检测的方法)

------解决方案--------------------
Delphi(Pascal) code

procedure Tform1.HartTimerTimer(Sender: TObject);
var
  CBLogin:TCBLogin;
  Buffer: array[1..2048] of char;
begin
  if ClientTCP.Connected = False then exit;
  try
    ClientTCP.WriteBuffer(skOnlineCheck, 1, True);
    //AutoService.IOer.AddShow('向服务端发送心跳测试',[]);
  except
      AutoService.IOer.AddShow('向服务端发送心跳测试失败************************',[]);
      Exit;
    end;
  end;

  if GetTickCount - LastReturnHartTick > HartTimer.Interval * 10 then
  begin
    AutoService.IOer.AddShow('心跳超时,自动断开并重新登陆',[]);
    ClientLogout();
    Exit;
  end;





end;