Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Aug : Re: WaitForMultipleObjects

www.cryer.info
Managed Newsgroup Archive

Re: WaitForMultipleObjects

Subject:Re: WaitForMultipleObjects
Posted by:"Bart van der Werf" (blueli..@xs4all.nl)
Date:Thu, 17 Aug 2006 12:17:04

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:44e3577b$1@newsgroups.borland.com...
>
> "Bart van der Werf" <bluelive@xs4all.nl> wrote in message
> news:44e2f40b@newsgroups.borland.com...
>
>>     WSAEventSelect( FSocket.Socket.Binding.Handle, FEvent, FD_READ +
>> FD_CLOSE);
>
> Indy uses (and requires) blocking sockets.  WSAEventSelect() cannot
> produce
> those kinds of events for blocking sockets.  Worse, WSAEventSelect()
> forces
> the specified socket into a non-blocking mode, which will break Indy.

Which is somethign i was affraid of, im currently recoding all of it to use
winsock directly.

>>    WaitForManyObjects(@FEvent, 1, False, INFINITE);
>
> Since you are only waiting on a single connection, just use Indy's own
> Readable() method instead:
>
>    if FSocket.IOHandler.Readable(IdTimeoutInfinite) then
>        ...
>
> However, I have to question your motives, because under normal
> circumstances, you should not be waiting like that to begin with.  What
> EXACTLY are you trying to accomplish?

I have multiple connections and a thread that is not fully dedicated to the
task of blocking on these connections if they are inactive, and i have some
more events that i must also monitor in the same waitfor (infact a complex
waitfor that allows me to workaround the 64 handle problem using threading)

>> how can i expose such functionality through INDY ?
>
> You have to store all of the desired socket handles into a list and then
> pass that to the socket API select() function.  How you do that exactly
> depends on the version of Indy that you are using, ie:
>
<Snip>

Ooh great examples :)

I might rethink rewriting it using winsock if i can find a way to also wait
for a few non indy handles.

grt, bart

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive