Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Porting old Delphi2007 application using TServerSocket....
(07-08-2020, 07:43 PM)BosseB Wrote: If readln timeouts will it return an empty string to msg?

Yes.  And the ReadLnTimedOut property will be set to True.

(07-08-2020, 07:43 PM)BosseB Wrote: I.e. it will leave the data in the buffer until the line ending char arrives?


(07-08-2020, 07:43 PM)BosseB Wrote: I don't want to have partial packets to deal with...

Unless you have other work to do, then just don't use a timeout at all, let ReadLn() wait until the ETX arrives.

(07-08-2020, 07:43 PM)BosseB Wrote:
msg := AContext.Connection.IOHandler.ReadLn(ETX, 10); //Timeout 10 ms

10ms is a very short timeout to use.

(07-08-2020, 07:43 PM)BosseB Wrote: I guess it must work that way because otherwise one can never know if a partial packet is present when processing it (the ETX char is "eaten" by ReadLn)...

Alternatively, you can use WaitFor() instead, which has an AInclusive parameter which you can set to True to include the terminator in the output.  However, WaitFor() will raise an exception on a timeout, rather than return an empty string.

(07-07-2020, 10:33 AM)BosseB Wrote: I can run the server on both platforms and connect to each by changing the host value, and when connecting to the Linux server the response is immediate. The login dialog appears instantly, whereas if I connect to the Windows based server there is a delay of maybe 5 seconds before that happens.

Then the delay is most likely outside of the server's code. I just could not tell you where exactly.


Messages In This Thread
RE: Porting old Delphi2007 application using TServerSocket.... - by rlebeau - 07-09-2020, 06:47 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)