How to achieve blocking timeout with LNET? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Awesome Programmer · 2016-11-08 16:06 I am using LNET Component to talk from SOCKET TO SOCKET using TCP/IP protocol. After reading many topics and replies on this topic, I take it that LNET doesn't really have reliable TIMEOUT feature. So, how do you implement BLOCKING TIMEOUT with LNET component without restoring to WHILE LOOP or Worse using SLEEP(X) procedure all over your code? That's what I am forced to do. It works fine for the most part and other times it acts goofy and data becomes corrupted. ---------------------------------------------------------------------- derek.john.evans · 2016-11-08 18:19 Do you meant INET? Windows? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses WinSock2;procedure SocketUnblock(const ASocket: TSocketStream);var  LMode: dword;begin  LMode := 1;  ioctlsocket(ASocket.Handle, longint(FIONBIO), @LMode);end;     There is some Windows info here: http://stackoverflow.com/questions/9847441/setting-socket-timeout I tend to just keep reading until I get data or timeout. Im guessing Linux would be a similar idea. https://www.scottklement.com/rpg/socktut/nonblocking.html Either way, if you have the handle of the underlining socket, you should be able to adjust the socket flags. ---------------------------------------------------------------------- Leledumbo · 2016-11-08 20:15 Well, according to this, for visual component the timeout is ignored because its visual components integrates to event loop instead (trust Almindor, he's lNet's author). Your best bet would be to use a TTimer (which itself runs in a separate thread) which sends request on the first tick (OnTimer call) then terminates on the next, while disabling the timer as well. Of course when it actually works before the timeout, you must disable it as soon as possible or you might get corrupted data. ---------------------------------------------------------------------- Awesome Programmer · 2016-11-08 20:16 Opps sorry... this is for Linux Lazarus. ---------------------------------------------------------------------- Awesome Programmer · 2016-11-09 21:43 Quote from: Leledumbo on November 08, 2016, 09:15:31 pmWell, according to this, for visual component the timeout is ignored because its visual components integrates to event loop instead (trust Almindor, he's lNet's author). Your best bet would be to use a TTimer (which itself runs in a separate thread) which sends request on the first tick (OnTimer call) then terminates on the next, while disabling the timer as well. Of course when it actually works before the timeout, you must disable it as soon as possible or you might get corrupted data. Hi Leledumbo, I am really a newbie when it comes this sort of things. If it is not too much of a trouble, can you show me a simple or basic pseudo code on how to use TTimer to timeout with LNET? Thank you.