how to know there is data in the buffer using sockets unit lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- arturogr · 2023-12-12 02:43 Hello:  I am using windows, and I want to know if there is an option (function), to know if there is data in the in-buffer socket of a connection; so I can call the fpRecv funtion to read the data in the in-buffer. If I call fpRecv, the program halts, wainting for information to reach the program. But I want to do some thing else in a loop, while wainting for data. I found something like fpSelect() in the forum, but that function is not recognized in sockets unit, and I do not find any documentation for that: 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 if(fpSelect(FSocket + 1,@RTFD,nil,nil,@Timeout) > 0) then       begin         Len := fpRecv(FSocket,@Bytes_In,256,0);       end; By the other hand, I have read something like "ioctl", but with no examples to handle the same goal. thank you. ---------------------------------------------------------------------- olly · 2023-12-12 03:02 Take a look at https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/fcl- net/src/ssockets.pp#L306 lots of cross platform examples there. For Windows you'll want the winsock2 unit to get access for ioctlsocket and select functions. ---------------------------------------------------------------------- MarkMLl · 2023-12-12 08:13 Use the FIONREAD ioctl. Example below was originally written for serial data but should be about right 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 FUNCTION MinDataAvailable(handle: INTEGER): INTEGER; begin (* If the handle is invalid (port not open) or there is an error then return < 0. *)   if handle = InvalidSerialHandle then    result := -1  else begin    if fpIoctl(handle, FIONREAD, @result) <> 0 then      result := -1  endend { MinDataAvailable } ;  MarkMLl