Skip to content

Change System.Net.WebSockets contract for WebSocketReceiveResult #15717

Closed
@benaadams

Description

@benaadams

Follow up from "Resuable WebSocketReceiveResult" dotnet/corefx#4520

At the moment is WebSocketReceiveResult is a read only POCO type that as a class must be garbage collected on every single socket message; probably gen0; but still bad for high speed websockets.

I can see two approaches to address this:

  1. Change the setters to protected, which opens up a possibility for types derived from System.Net.WebSockets.WebSocket to reuse the result object using a derived WebSocketReceiveResult type.
  2. Change type from class to struct.

Either approach halves the number of allocations, second is safer but allocates more memory. (Though ValueTask returns could change this)

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-needs-workAPI needs work before it is approved, it is NOT ready for implementationarea-System.Netdesign-discussionOngoing discussion about design without consensushelp wanted[up-for-grabs] Good issue for external contributors

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions