The SpinWait call in TcpModbusSocket.Receive causes delay


Using default values, the fastest you can receive data over ModBus TCP is about 1.1 seconds. The messages were a lot faster, so I looked into the code.

I ended up adding a break; to right after retrTime = 0; on line 122. I think that if data is received from the socket, we should immediately return it.

File: TcpModebusSocket

Thanks for providing this library on NuGet! It made my first foray into Modbus a happy one!