{"id":28547480,"url":"https://github.com/pingmantools/system.net.websockets.client.managed","last_synced_at":"2025-07-07T18:31:11.739Z","repository":{"id":60773971,"uuid":"82335981","full_name":"PingmanTools/System.Net.WebSockets.Client.Managed","owner":"PingmanTools","description":"Microsoft's managed implementation of System.Net.WebSockets.ClientWebSocket tweaked for use on Windows 7 and .NET 4.5","archived":false,"fork":false,"pushed_at":"2018-11-04T03:15:28.000Z","size":80,"stargazers_count":46,"open_issues_count":9,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-09T20:38:58.747Z","etag":null,"topics":["clientwebsocket","websocket-client","websockets","websocketsharp"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PingmanTools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-17T20:38:15.000Z","updated_at":"2025-05-23T14:26:11.000Z","dependencies_parsed_at":"2022-10-04T15:30:28.723Z","dependency_job_id":null,"html_url":"https://github.com/PingmanTools/System.Net.WebSockets.Client.Managed","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PingmanTools/System.Net.WebSockets.Client.Managed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingmanTools%2FSystem.Net.WebSockets.Client.Managed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingmanTools%2FSystem.Net.WebSockets.Client.Managed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingmanTools%2FSystem.Net.WebSockets.Client.Managed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingmanTools%2FSystem.Net.WebSockets.Client.Managed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PingmanTools","download_url":"https://codeload.github.com/PingmanTools/System.Net.WebSockets.Client.Managed/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingmanTools%2FSystem.Net.WebSockets.Client.Managed/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264130499,"owners_count":23562038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clientwebsocket","websocket-client","websockets","websocketsharp"],"created_at":"2025-06-10T00:30:32.980Z","updated_at":"2025-07-07T18:31:11.726Z","avatar_url":"https://github.com/PingmanTools.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# System.Net.WebSockets.Client.Managed\nMicrosoft's managed implementation of System.Net.WebSockets.ClientWebSocket tweaked for use on Windows 7 and .NET 4.5\n\n---\n\nFrom Microsoft's [ClientWebSocket documentation](https://msdn.microsoft.com/en-us/library/system.net.websockets.clientwebsocket(v=vs.110).aspx)\n\u003e Some of the classes and class elements in the System.Net.WebSockets namespace are supported on Windows 7, Windows Vista SP2, and Windows Server 2008. **However, the only public implementations of client and server WebSockets are supported on Windows 8 and Windows Server 2012.** The class elements in the System.Net.WebSockets namespace that are supported on Windows 7, Windows Vista SP2, and Windows Server 2008 are abstract class elements. This allows an application developer to inherit and extend these abstract class classes and class elements with an actual implementation of client WebSockets.\n\nIn other words: on a Windows 7 machine calling `new System.Net.WebSockets.ClientWebSocket()` throws a `PlatformNotSupportedException`. \n\nThankfully Microsoft did implement that abstract class in managed code for use on non-Windows systems! But its only available for .NET 4.6+\n\nThis project is the managed System.Net.WebSockets.Client code with a few tweaks to work on .NET 4.5.\n\nThe code was taken from the CoreFX `release/2.0.0` branch on Nov 28th, 2017:\n* [System.Net.WebSockets.Client/src/System/Net/WebSockets](https://github.com/dotnet/corefx/tree/17c427343d7f2e9321f96a5615e4f0687878cfcf/src/System.Net.WebSockets.Client/src/System/Net/WebSockets)\n* [System.Net.WebSockets/src/System/Net/WebSockets](https://github.com/dotnet/corefx/tree/17c427343d7f2e9321f96a5615e4f0687878cfcf/src/System.Net.WebSockets/src/System/Net/WebSockets)\n* [System.Net.WebSockets/src/Common/src/System/Net/WebSockets](https://github.com/dotnet/corefx/tree/17c427343d7f2e9321f96a5615e4f0687878cfcf/src/Common/src/System/Net/WebSockets)\n\n---\n\nMost the tweaks required are in the added files `NET45Shims.cs` and `SR.cs`, with a few changes to the original source when extensions methods could not be leveraged (NET46-only properties and statics). \n\nThe only actual NET 4.6+ features used were some Task helpers (Task.FromException, Task.FromCanceled, Task.CompletedTask) and the Socket.ConnectAsync task. Microsoft could easily fix these and provide an official nuget package like this to support Win7 and .NET 4.5.\n\n## Install\n\nNuget package as [System.Net.WebSockets.Client.Managed](https://www.nuget.org/packages/System.Net.WebSockets.Client.Managed/)\n\n`PM\u003e Install-Package System.Net.WebSockets.Client.Managed`\n\n## Usage\n\n`System.Net.WebSockets.SystemClientWebSocket` class has some helpers for easily creating a ClientWebSocket that will work on the current system. \n\n```cs\n// Creates a ClientWebSocket that works for this platform. Uses System.Net.WebSockets.ClientWebSocket if supported or System.Net.WebSockets.Managed.ClientWebSocket if not.\npublic static WebSocket SystemClientWebSocket.CreateClientWebSocket() { ... }\n\n// Creates and connects a ClientWebSocket that works for this platform. Uses System.Net.WebSockets.ClientWebSocket if supported or System.Net.WebSockets.Managed.ClientWebSocket if not.\npublic static async Task\u003cWebSocket\u003e ConnectAsync(Uri uri, CancellationToken cancellationToken)\n```\n\nIf you know you want a managed instance than use `new System.Net.WebSockets.Managed.ClientWebSocket()` rather than `new System.Net.WebSockets.ClientWebSocket()`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingmantools%2Fsystem.net.websockets.client.managed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpingmantools%2Fsystem.net.websockets.client.managed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingmantools%2Fsystem.net.websockets.client.managed/lists"}