Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Dec : Re: TidTCPServer from delphi 6

www.cryer.info
Managed Newsgroup Archive

Re: TidTCPServer from delphi 6

Subject:Re: TidTCPServer from delphi 6
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Thu, 27 Dec 2007 10:24:49

"Nicoara Adrian" <adisoftbn@yahoo.com> wrote in message
news:47738a97$1@newsgroups.borland.com...

> TIdPeerThread(List.Items[Count]).Connection.WriteLn(Msg);

Like I said earlier, you need to implement your own locking mechanism to
protect your broadcast message from overlapping any writes that may be
performed elsewhere by your server in response to client messages at the
same time you are performing the broadcast.  Calling Threads.LockList() by
itself is NOT enough.  If you don't protect your writes from overlapping,
you are going to corrupt your data.  You need to either use a per-connection
synchronization objec, such as a critical section or mutex, around each
individual write operation, or you need to implement a per-connection
outbound queue instead, and have the server check the queue periodically.
Examples of both have been posted many times before.  Search the newsgroup
archives at http://www.deja.com.

> TIdPeerThread(List.Items[Count]).Stop;

Do not do that.  You should disconnect the connection, but do not Stop() the
thread itself.  Let the server manage that on its own.


Gambit

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive