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.

--
[EMAIL PROTECTED]
http://www.overbyte.be


----- Original Message ----- 
From: "Markus Humm" <[EMAIL PROTECTED]>
To: <twsocket@elists.org>
Sent: Sunday, May 01, 2005 9:49 AM
Subject: [twsocket] ReadLine


> Hello,
>
> I'm using TWSocket for UDP communications, so far it works quite good.
> 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.
>
> If I use ReadLine with a 50 ms timeout, my program handg, until the
> close button is pressed (x right corner of the window). Then is
> continues but hasn't read anything. If I don't press that button it
> doesn't continue!
>
> How to use ReadLine properly? In the help was something with Wait
> statet, but the property where you should assign that wait object to
> doesn't exist (any more).
>
> Do you have a short sample?
>
> I'm using D2005 Arch. SP1 german on Windows XP SP2.
>
> Greetings
>
> Markus
>
> -- 
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://www.elists.org/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to