Namespace: System.Net.Sockets

SocketAsyncLogOptionsFlags Enumeration

Specifies options for logging asynchronous socket operations.

Summary

The SocketAsyncLogOptionsFlags enumeration is used to control the level of detail logged for asynchronous socket operations. This can be useful for debugging and monitoring network activity within your application.

Members

None
No logging options are enabled. This is the default value.
LogAll
Logs all available information for asynchronous socket operations. This is the most verbose option and should be used with caution in production environments due to potential performance impact.
LogParameters
Logs the parameters passed to asynchronous socket methods (e.g., buffer, offset, size).
LogResults
Logs the results returned by asynchronous socket methods (e.g., bytes transferred, error codes).
LogExceptions
Logs any exceptions that occur during asynchronous socket operations.
LogDispose
Logs when a Socket object is disposed.
LogClose
Logs when a Socket is closed.

Usage Example

You can combine these flags using the bitwise OR operator (|) to specify multiple logging options.


using System.Net.Sockets;

// ...

// Enable logging of parameters and results for asynchronous operations
SocketAsyncLogOptionsFlags logOptions = SocketAsyncLogOptionsFlags.LogParameters | SocketAsyncLogOptionsFlags.LogResults;

// When initiating an asynchronous operation, you might pass these options:
// someSocket.AcceptAsync(..., logOptions);
// someSocket.ReceiveAsync(..., logOptions);
            

Remarks

Related Topics