.NET API Browser

Explore the .NET Framework and .NET Core APIs

SocketAsyncLogOptions Enum

Namespace: System.Net.Sockets
Assembly: System.Net.Primitives (in System.Net.Primitives.dll)
Implemented in: .NET Framework 4.5, .NET Core 1.0, .NET 5.0 and later

Description

Specifies options for logging asynchronous socket operations. This enumeration is used with the Socket.SetSocketOption method to control the level of detail and types of asynchronous operations that are logged.

This enum allows developers to enable or disable logging for different stages of asynchronous socket operations, aiding in debugging and performance analysis.

Members

None

None

No asynchronous socket logging is enabled.

LogStackDepth

LogStackDepth

Logs the call stack depth for asynchronous socket operations. This can be useful for understanding nested asynchronous calls.

LogSocketError

LogSocketError

Logs the SocketError value when an asynchronous operation completes with an error.

LogSocketCreate

LogSocketCreate

Logs the creation of new Socket objects.

LogSocketClose

LogSocketClose

Logs when Socket objects are closed or disposed.

LogAll

LogAll

Logs all available information for asynchronous socket operations. This is equivalent to enabling all other logging options.

Usage Example


// Enable logging for errors and stack depth
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.AsyncLogSettings,
    SocketAsyncLogOptions.LogSocketError | SocketAsyncLogOptions.LogStackDepth);

// To log everything:
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.AsyncLogSettings,
    SocketAsyncLogOptions.LogAll);

// To disable logging:
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.AsyncLogSettings,
    SocketAsyncLogOptions.None);