WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection.
The WebSocket protocol enables interaction between a web browser (or other client application, like .NET Application) and a web server with lower overhead than half-duplex alternatives such as HTTP polling, facilitating real-time data transfer from and to the server. This is made possible by providing a standardized way for the server to send content to the client without being first requested by the client, and allowing messages to be passed back and forth while keeping the connection open. In this way, a two-way ongoing conversation can take place between the client and the server.
Unlike HTTP, WebSocket provides full-duplex communication.Additionally, WebSocket enables streams of messages on top of TCP. TCP alone deals with streams of bytes with no inherent concept of a message.
The WebSocket protocol specification defines ws (WebSocket) and wss (WebSocket Secure) as two new uniform resource identifier (URI) schemes that are used for unencrypted and encrypted connections, respectively.
sgcWebSockets library allow to build .NET WebSocket Servers and Clients.
sgcWebSockets for .NET
HandShake
To establish a WebSocket connection, the client sends a WebSocket handshake request, for which the server returns a WebSocket handshake response, as shown in the example below.
Client Request
GET /chat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Version: 13
Origin: http://example.com
Server Response
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
sgcWebSockets .NET
sgcWebSockets is a complete package providing access to WebSockets protocol, allowing to create WebSockets Servers and Clients for .NET Applications.
- Fully functional multithreaded WebSocket server according to RFC 6455.
- Supports Windows 32 / Windows 64
- Assemblies for .NET FRAMEWORK (2.0+), .NET STANDARD (1.6+), .NET CORE (1.0+).
- Supports Chrome, Firefox, Safari, Opera and Internet Explorer (including iPhone, iPad and iPod)
- Multiple Threads Support. Indy Servers support IOCP or default Indy one thread per connection model.
- Supports Message Compression using PerMessage_Deflate extension RFC 7692.
- Supports Text and Binary Messages.
- Supports Server and Client Authentication.
- Server component providing WebSocket and HTTP connections through the same port.
- FallBack support through Adobe Flash for old Web Browsers like Internet Explorer from 6+.
- Supports Server-Sent Events (Push Notifications) over HTTP Protocol.
- WatchDog and HeartBeat built-in support.
- Client WebSocket supports connections through HTTP Proxy Servers and SOCKS Proxy Servers.
- Events Available: OnConnect, OnDisconnect, OnMessage, OnError, OnHandshake
- Built-in Javascript libraries to support browser clients.
- Easy to setup
- Javascript Events for full control
- SSL/TLS Support for Server / Client Components (OpenSSL libraries required). OpenSSL 1.1.1 libraries are supported. Client supports SChannel for Windows.
.NET Supported Versions
- .NET Framework 2.0+
- .NET Standard 1.6+
- .NET Core 1.0+
- VSIX Package requires .NET Framework 4.5
- Supports Windows 32 / Windows 64 (requires sgcWebSockets.dll library)
Quickstart
Find below some articles to how use sgcWebSockets .NET controls.