Windows Dev Center

StreamWebSocket.Close(UInt16, String) | close(UInt16, String) method

Closes the StreamWebSocket and indicates a reason for the closure.

Syntax


streamWebSocket.close(code, reason);

Parameters

code

Type: Number [JavaScript] | System.UInt16 [.NET] | uint16 [C++]

Status code indicating the reason for closure.

The following values are supported:

ValueMeaning
1000

The purpose of the connection has been fulfilled and the connection is no longer needed.

1001

An endpoint is no longer available (such as when a server is no longer available or a browser has navigated away from a webpage).

1002

A protocol error has occurred.

1003

The endpoint cannot receive this type of data.

1005

An empty close frame was received.

Note  When code is set to 1005, the reason parameter must be an empty string. Setting code to 1005 will send an empty close frame.
1007

Data within a message is not consistent with the type of the message.

1008

The message violates an endpoint's policy.

1009

The message is too large to process.

1010

A client endpoint expected the server to negotiate one or more extensions, but the server didn't return them in the response message of the WebSocket handshake. The list of extensions that are needed should appear in the reason parameter.

 

Status codes in the range 0-999 are not used.

Status codes in the range 1000-2999 are reserved for definition by the WebSocket protocol.

Status codes in the range 3000-3999 are reserved for use by libraries, frameworks, and applications. These status codes are registered directly with IANA. The interpretation of these codes is undefined by the WebSocket protocol.

Status codes in the range 4000-4999 are reserved for private use and cannot be registered. Such codes can be used by prior agreements between WebSocket applications. The interpretation of these codes is undefined by the WebSocket protocol.

reason

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

Optional UTF-8-encoded data with additional information about the closure.

Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Networking.Sockets
Windows::Networking::Sockets [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Networking.Sockets
Windows::Networking::Sockets [C++]

Metadata

Windows.winmd

See also

StreamWebSocket
Close

 

 

Show:
© 2015 Microsoft