idris-lang / Idris-dev

A Dependently Typed Functional Programming Language
http://idris-lang.org
Other
3.43k stars 644 forks source link

Problems with recvAll in Network.Socket contrib Library #4868

Open FrederikVigen opened 4 years ago

FrederikVigen commented 4 years ago

We have tried to use the recvAll functionality in the Network.Socket library from the contrib package. It seems that when it runs recursively into the recv on an empty buffer, it is blocking and not receiving the clean exit (Left 0) signal, thus running infinitely and never returning. We propose a solution to this issue that instead of waiting for a Left 0 signal, the function runs recursively until then buffer size is smaller than the reading size that it is trying to achieve. The solution looks something like this: https://pastebin.com/vZx6YxNh We would like to know if you have any problems with the iteration of the code that we have done, or for that matter if you have any idea of improvement.

The exact code that this revision relates to is: https://github.com/idris-lang/Idris-dev/blob/master/libs/contrib/Network/Socket.idr

melted commented 4 years ago

Hi! I think it's a great improvement. Please submit a PR.

If you want to you can see if the same fix applies to Idris 2: https://github.com/idris-lang/Idris2.