Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Aug : Re: TIdUDPClient and other indy clients
| Subject: | Re: TIdUDPClient and other indy clients |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Sun, 20 Aug 2006 19:10:36 |
"Miraka" <ak_47@abv.bg> wrote in message
news:44e80e21$1@newsgroups.borland.com...
> How can I determine if the TIdUDPClient is ready to read the data..
The only way to check for readibility, without actually reading, is to call
the Binding's Readable() method. Otherwise, just read and let the client
block until the data arrives. That is how Indy is primarily designed to be
used.
> there is no OnRead event.
For the large part, Indy is not an event driven library to begin with. Do
not rely on events in client components (except for TIdTelnet or TIdIRC,
which do have events when data arrives) to do your work. Just call a
reading method and wait for the data to arrive. If you do not want to block
the main UI
thread, then do the reading in a worker thread.
> I know thaht Indy is blocking
You are asking for a non-blocking solution.
> but isn't there a way to read the data only when it is available
Indy (and blocking sockets in general) is designed to wait until the data is
available. Call a reading method, and it will not exit until the data
arrives, or until a timeout occurs.
> I don't want to use TIdAntiFreeze
Then you have to do blocking reads in a worker thread. That is how Indy
servers are able to provide such events, by the way.
Gambit
none