Checking the socket buffer prior to recv
is more flexible rather than covering a lot for select()
support, I think. You can call ioctlsocket(SockHandle, FIONREAD, Longint(CountInBuffer))
to see if there's data in network buffer to read and then call recv(SockHandle, buff, CountInBuffer, 0)
. This way you can make a single recv call to read the whole network read buffer if you allocate the buff itself enough with CountInBuffer. Otherwise, you need to call recv in a loop to read the network buffer, which is the traditional way. In both cases, you're still in the constraints of the CountInBuffer
.