endel / NativeWebSocket

🔌 WebSocket client for Unity - with no external dependencies (WebGL, Native, Android, iOS, UWP)
Other
1.2k stars 158 forks source link

Is there a way to deactivate Nagle algorithm / use TCP_NODELAY #57

Closed maeln closed 2 years ago

maeln commented 2 years ago

For a lot of application, Nagle algorithm (https://en.wikipedia.org/wiki/Nagle%27s_algorithm) can add significant unwanted latency. For this reason, most library expose a way to deactivate Nagle algorithm when using websocket (ex: https://docs.microsoft.com/en-us/uwp/api/windows.networking.sockets.streamwebsocketcontrol.nodelay?view=winrt-22000).

Does NativeWebSocket provide a way to deactivate Nagle algorithm ?

endel commented 2 years ago

Afaik there is no way to disable Nagle algorithm from the client-side. The server is the one responsible for using (or not using) Nagle algorithm.

As NativeWebSocket is just a WebSocket client, you could for example send some extra parameters on the query string or headers, and enable/disable Nagle based on that on the server.