Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Apr : Re: TIdTCPServer - threads, global data contd.

www.cryer.info
Managed Newsgroup Archive

Re: TIdTCPServer - threads, global data contd.

Subject:Re: TIdTCPServer - threads, global data contd.
Posted by:"Stephen Odgaard" (s..@cowi.dk)
Date:Sun, 16 Apr 2006 01:58:00

Trying to answer some of my own questions. (please correct me if im wrong or
an unsafe route)
I should just mention that im using Indy v. 10

It seems the key to 1a) and 1d) would be to maintain a TThreadlist of
connected TIDContext's with their individual data.
1c) should then be possible to perform by getting the AContext from the
TThreadlist above and then a) either executing the AContext.OnRun event, or
b)even simpler by executing AContext.Connection.IOHandler.WriteLn()

Is the above understanding/approach correct and safe?
That leaves questions 1b), 2a), and 2b) open.

Cheers

Stephen

"Stephen Odgaard" <sso@cowi.dk> wrote in message
news:44417f5b@newsgroups.borland.com...
>I have with interest read the thread by Mathijs, Martin James and Remy
>Lebeau on the above topic.
>
> I am also in the process of implementing my first IdTCPServer, so I need
> to get some basics straight here.
>
> The purpose of the Application is to work as a sort of Router, which means
> that I have to send data from Clients connected, but I also have data
> initiated by the server (or other Clients to be sent to a given Client)
>
> As I read the thread the conclusion is that data should be stored in eg. a
> TThreadList, or in a special strucuture with a critical section. A couple
> of questions:
>
> Reg. the OnExecute Event handler:
> 1a) Can I from the main thread get access to a list of connected clients
> (ie. with connected clients)
> 1b) What initiatiates the OnExecute Event?
> 1c) How can I (eg. from the main thread) "provoke" the OnExecute Event
> handler of a given client to be executed in order to empty an outbound
> info queue?
> 1d) How would you store data in relation to a specific client for use
> during later Execute handles (or another thread)?
>
> Thread safe global data.
> You mentioned the TThreadList as an example of storing threadsafe data.
> And alternatively to make ones own class with a critical section.
> 2a) Do you have an example of such a class implementation for my
> inspiration?
> 2b) Do you Mathijs have any working code example based on the discussion
> you had with Martin and Remy that you could share?
>
> Thanks in advance
>
> Stephen

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive