Francois PIETTE schrieb:
> As expressed in the source code, ReadLine is deprecated. Anyway, it doesn't
> fit correctly with UDP protocol which is datagram oriented. Using "lines"
> with such protocol is strange.
>>Now I have the problem that at one place in the program I need
>>synchronus communication. I send out one byte and if I receive the same
>>byte within some short timeout, I assume that the device I'm talking to
>>has a echo mode.
> Send your byte then program a loop waiting for the evnt OnDataAvailable to
> occur before a given time. Not the best practice, but that's how you can
> implement synchronous operation if you really need this (you can ALWAYS
> avoid synchronous operation).
> When you are in your wait loop, you must process events or your application
> will be locked. You must do something like that (not checked, out of my
> head) :
>         FReceiveFlag := FALSE;
>         WSocket1.Send(...your one byte data ....);
>         while not FReceiveFlag do begin
>             DummyHandle := INVALID_HANDLE_VALUE;
>             MsgWaitForMultipleObjects(0, DummyHandle, FALSE, 1000,
>                                       QS_ALLINPUT + QS_ALLEVENTS +
>                                       QS_KEY + QS_MOUSE);
>             Application.ProcessMessages;
>             if Application.Terminated then
>                 break;
>         end;
> OnDataAvailable handler will set the FReceiveFlag variable to TRUE.
> You can also use a TTimer to check for timeout.
Thanks for the reply, I will consider that tomorrow.
Normally I do asynchronos communication, but for the first test wether
my communication partner has echo or not I don't want this, I simply
want this one synchronous.

The thing is that the code is in a dll, so application.processmessages
might not work here. Or does it? The timeout will be rather short anyhow
(ca. 50 ms) and I think i do it with GetTickCount, which should be
sufficient here and more easy to use than a at this place timer.
Or is there anything bad with these ideas?


Markus Humm

To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at

Reply via email to