WebSocket.CreateFromStream Method

Definition

Overloads

CreateFromStream(Stream, WebSocketCreationOptions)

Creates a WebSocket that operates on a Stream representing a web socket connection.

CreateFromStream(Stream, Boolean, String, TimeSpan)

Creates a new WebSocket object that operates on the specified stream, which represents a web socket connection.

CreateFromStream(Stream, WebSocketCreationOptions)

Source:
WebSocket.cs
Source:
WebSocket.cs
Source:
WebSocket.cs

Creates a WebSocket that operates on a Stream representing a web socket connection.

C#
public static System.Net.WebSockets.WebSocket CreateFromStream(System.IO.Stream stream, System.Net.WebSockets.WebSocketCreationOptions options);

Parameters

stream
Stream

The Stream for the connection.

options
WebSocketCreationOptions

The options with which the websocket must be created.

Returns

The created web socket.

Applies to

.NET 10 and other versions
Product Versions
.NET 6, 7, 8, 9, 10

CreateFromStream(Stream, Boolean, String, TimeSpan)

Source:
WebSocket.cs
Source:
WebSocket.cs
Source:
WebSocket.cs

Creates a new WebSocket object that operates on the specified stream, which represents a web socket connection.

C#
public static System.Net.WebSockets.WebSocket CreateFromStream(System.IO.Stream stream, bool isServer, string? subProtocol, TimeSpan keepAliveInterval);
C#
public static System.Net.WebSockets.WebSocket CreateFromStream(System.IO.Stream stream, bool isServer, string subProtocol, TimeSpan keepAliveInterval);

Parameters

stream
Stream

The stream for the connection.

isServer
Boolean

true to indicate it's the server-side of the connection; false if it's the client-side.

subProtocol
String

The agreed upon sub-protocol that was used when creating the connection.

keepAliveInterval
TimeSpan

The keep-alive interval to use, or InfiniteTimeSpan to disable keep-alives.

Returns

The new web socket.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1