C# WebSocket server example: Incompatible type for "offset"
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_server
What specific section or headline is this issue about?
wsserver.cs in "Put together"
What information was incorrect, unhelpful, or incomplete?
From the following lines:
for (ulong i = 0; i < msglen; ++i) decoded[i] = (byte)(bytes[offset + i] ^ masks[i % 4]);
I got the error CS0034: Operator '+' is ambiguous on operands of type 'int' and 'ulong'. I fixed the problem by making offset a ulong. I do not know if that is the best solution.
Otherwise, the sample works.
What did you expect to see?
A clean build.
Do you have any supporting links, references, or citations?
Try the build yourself.
Do you have anything more you want to share?
No
MDN metadata
Page report details
- Folder:
en-us/web/api/websockets_api/writing_websocket_server - MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_server
- GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/websockets_api/writing_websocket_server/index.md
- Last commit: https://github.com/mdn/content/commit/0bced7ea55d93bc774e632611353bd76b6269c9e
- Document last modified: 2023-11-23T07:58:58.000Z
Hello! Cast offset to ulong type
The offset variable should be declared as a ulong in the first place.
Hi ! I would like to work on this issue.