Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Dec : Re: TidTCPServer from delphi 6
| Subject: | Re: TidTCPServer from delphi 6 |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Tue, 25 Dec 2007 13:37:25 |
"Nicoara Adrian" <adisoftbn@yahoo.com> wrote in message
news:477138fc@newsgroups.borland.com...
> I'm using indy from delphi 6.
Then you are likely using Indy 8, which is outdated and no longer supported.
> when a client connects i save his socket number
You are not saving the underlying TSocket handle, are you?
> on an array.
Is your array protected from multi-threaded access?
> how do i send an message from server to all clients
You have to loop through the list pointed to by the server's Threads
property. Each entry is a pointer to a TIdPeerThread object. You can write
to each client via that object, just like you normally do when replying to
client messages. You will have to implement your own locking mechanism,
though, so your server's broadcast messages do not overlap client message
replies that may be sent at the same time. Indy does not prevent multiple
threads from reading from, or writing to, a socket from multiple threads at
the same time, so you have to manage that yourself manually. If you go to
http://www.deja.com and search the newsgroup archives, examples of a few
different techniques have been posted many times before.
> or to a specified client via socket number ?
Again, you have to loop through the server's Threads list looking for the
TIdPeerThread object that you are interested in.
Gambit