content icon indicating copy to clipboard operation
content copied to clipboard

C# WebSocket server example: Incompatible type for "offset"

Open SamHobbsOrg opened this issue 1 year ago • 3 comments

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

SamHobbsOrg avatar Jan 18 '24 02:01 SamHobbsOrg

test

Hello! Cast offset to ulong type

sambatya1 avatar May 07 '24 15:05 sambatya1

The offset variable should be declared as a ulong in the first place.

Josh-Cena avatar Jun 05 '24 08:06 Josh-Cena

Hi ! I would like to work on this issue.

ramshankarb avatar Aug 06 '24 09:08 ramshankarb