Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : Re: IdTCPServer

www.cryer.info
Managed Newsgroup Archive

Re: IdTCPServer

Subject:Re: IdTCPServer
Posted by:"Jamie Dale" (j.da..@turboz.net)
Date:Sun, 11 Jun 2006 00:07:21

>> well either way it using an array still allows me to keep all the
>> users data and a pointer to the AThread. That means I can find
>> their connection and write to it fairly easily.
>
> You don't need to do any of that.

That doesn't surprise me... but its the only way I know.

>> Imagine if I assigned their info to the Thread data - I'd need
>> blank threads for the users that wern't even logged on etc.
>
> No, you don't.  Just access the threads that are already running when
> needed.  If a user is not logged in, there would not be any thread at all.

No, but I would still need to access that users data and modify it etc.
Thats why I chose to use an array because I can access all users in the same
place. Using Thread.Data means I can only access those online so the offline
users must be accessed somewhere else. I don't really want to be
looking/modifying things all over the place.

>> Using an array makes it a lot easier from my POV.
>
> Only because you don't know any better yet.

But one day...!

> There are other ways to store
> data more effectively.  For example:

>> Also, seeing as each thread has access to the array, how can
>> I stop it being damaged/corrupted?
>> Can you provide any sample codes?
>
> One way would be to stop using an array to begin with.

True/Maybe but see my comments above..

> Another way would be to lock access to the array using a critical section,
> which was already suggested to you in an earlier discussion.

Yes but until you showed me a critical section in this sample I had no idea
a) what they were b) how to use them or c) how to implement one.

Any chance you can provide more details on the critical section please?

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive