Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Jan : TIdTcpServer Disconnect while Read?

www.cryer.info
Managed Newsgroup Archive

TIdTcpServer Disconnect while Read?

Subject:TIdTcpServer Disconnect while Read?
Posted by:"Michael Stieler" (micha..@stieler.it)
Date:Wed, 30 Jan 2008 23:00:34

Hi,

  in our app we use a TIdTcpServer of Indy 10.

To handle the connections, save state et cetera there is a TConnection
object, which is created when a new connection is received and stored in
Context.Data. Now in the ServerExecute I call something like

  // strBuffer := (read from input buffer)
  TConnection(AContext.Data).Read( strBuffer );

Now we have a rare case of an access violation and I wanted to know if
it could happen, that the Server executes the ClientDisconnect
method/event and Frees the AContext.Data object WHILE the ServerExecute
is still using this object.
It seems to have happend after many hours of error free running so it
must be somehing very rare. Is the ClientDisconnect event raised from
another thread? If yes, should my solution work, if I put both
procedures inside a CriticalSection Enter/Leave?
That way the ClientDisconnect method should pause until the
ServerExecute finished?

Michael

Replies:

www.cryer.info
Managed Newsgroup Archive