Skip to content

Commit 7a0f425

Browse files
authored
Update README.md
1 parent 2fcf9bc commit 7a0f425

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,18 @@ FSharp.Control.WebSockets wraps [dotnet websockets](https://docs.microsoft.com/e
55

66
### Why?
77

8-
Dotnet websockets only allow for one receive and one send at a time. If multiple threads try to write to a websocket, it will throw a `System.InvalidOperationException` with the message `There is already one outstanding 'SendAsync' call for this WebSocket instance. ReceiveAsync and SendAsync can be called simultaneously, but at most one outstanding operation for each of them is allowed at the same time.`. This wraps a websocket in a FIFO that allows for multiple threads to write or read at the same time. See https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets.websocket.sendasync?view=netcore-2.0#Remarks
8+
9+
#### Thread safety
10+
11+
Dotnet websockets only allow for one receive and one send at a time. If multiple threads try to write to a websocket, it will throw a `System.InvalidOperationException` with the message `There is already one outstanding 'SendAsync' call for this WebSocket instance. ReceiveAsync and SendAsync can be called simultaneously, but at most one outstanding operation for each of them is allowed at the same time.`. This wraps a websocket in a FIFO that allows for multiple threads to write or read at the same time. See [Websocket Remarks](https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets.websocket.sendasync?view=netcore-2.0#Remarks) on Microsoft for more information.
12+
13+
#### F# friendly and correct behavior
14+
15+
This provides a `readMessage` type function. This is the biggest stumbling block people have when working with websockets. You have to keep reading from the message until it’s finished. People either don’t and end up having corrupted messages with a small buffer or have a buffer that is giant and can be a memory hog for smaller messages.
16+
17+
#### Memory usage
18+
19+
Uses [RecyclableMemoryStreamManager](https://www.philosophicalgeek.com/2015/02/06/announcing-microsoft-io-recycablememorystream/) and [ArrayPool](https://docs.microsoft.com/en-us/dotnet/api/system.buffers.arraypool-1?view=netstandard-2.1) to help keep memory usage and GC down.
920

1021
---
1122

0 commit comments

Comments
 (0)