Open techmindful opened 2 years ago
Hi i know this question is a bit old but i was wondering the same. So far i found out that receiveDataMessage doesn't block "especially". Yes it's recursive for control message but a normal message it returns. It does block the same receive
and receiveData
blocks.
Blocking works on makeSocketStream eventually you will get into socket code recvBuf and friends which use functions from base throwErrnoIfRetryMayBlock.
Where it creates the actual blocking functionality (yielding thread control until next packet comes in), i haven't been able to find.
Also note that the code on the front page
meow :: WS.Connection -> IO ()
meow conn = forever $ do
msg <- WS.receiveData conn
WS.sendTextData conn $ msg `T.append` ", meow"
has it's own "blocking" going on with forever
. That seems to be just a design choice of this library that you have to create your own loops. I'm not sure how you would break out of that forever
loop, possibly after closing the connection either the receive or send function will throw an exception. (i assume but didn't test).
Hope this helps
The documentation of this function here doesn't mention how it blocks execution, until a message is received from the websocket. This can cause confusion.