Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 May : Cleanup after disconnect

www.cryer.info
Managed Newsgroup Archive

Cleanup after disconnect

Subject:Cleanup after disconnect
Posted by:"AntonE" (anto..@true.co.za)
Date:Fri, 18 May 2007 22:05:20

In my (Indy10) TCPserver, I have code in OnConnect:


  AContext.Connection.IOHandler.WriteLn('TrueCalendar3 server ready...');
  AContext.Connection.IOHandler.WriteLn('Version 1');
  AContext.Data := TUserData.Create;
  TUserData(AContext.Data).PeerIP
:=AContext.Connection.Socket.Binding.PeerIP;
  TUserData(AContext.Data).HostName
:=GStack.HostByAddress(TUserData(AContext.Data).PeerIP);
  TUserData(AContext.Data).Connected :=Now;
  TUserData(AContext.Data).LastAction:=Now;


1)Now if he connection closes by client sending disconnect, will the
TUserData be freed automatically.
2)If so, then if the user disconnects by some unforseen method (network
failure), would it also be freed automatically?

I just do not want memory leaks to be present.

Thanks
AntonE

Replies:

www.cryer.info
Managed Newsgroup Archive