Table of Contents

Interface IConnection

Namespace
MongoDB.Driver.Core.Connections
Assembly
MongoDB.Driver.Core.dll

Represents a connection.

public interface IConnection : IDisposable
Inherited Members

Properties

ConnectionId

Gets the connection identifier.

ConnectionId ConnectionId { get; }

Property Value

ConnectionId

The connection identifier.

Description

Gets the connection description.

ConnectionDescription Description { get; }

Property Value

ConnectionDescription

The connection description.

EndPoint

Gets the end point.

EndPoint EndPoint { get; }

Property Value

EndPoint

The end point.

Generation

Gets the generation of the pool when this connection was created.

int Generation { get; }

Property Value

int

The generation of the pool when this connection was created.

IsExpired

Gets a value indicating whether this instance is expired.

bool IsExpired { get; }

Property Value

bool

true if this instance is expired; otherwise, false.

Settings

Gets the connection settings.

ConnectionSettings Settings { get; }

Property Value

ConnectionSettings

The connection settings.

Methods

Open(CancellationToken)

Opens the connection.

void Open(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token.

OpenAsync(CancellationToken)

Opens the connection.

Task OpenAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A Task.

ReceiveMessage(int, IMessageEncoderSelector, MessageEncoderSettings, CancellationToken)

Receives a message.

ResponseMessage ReceiveMessage(int responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

responseTo int

The id of the sent message for which a response is to be received.

encoderSelector IMessageEncoderSelector

The encoder selector.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

Returns

ResponseMessage

The response message.

ReceiveMessageAsync(int, IMessageEncoderSelector, MessageEncoderSettings, CancellationToken)

Receives a message.

Task<ResponseMessage> ReceiveMessageAsync(int responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

responseTo int

The id of the sent message for which a response is to be received.

encoderSelector IMessageEncoderSelector

The encoder selector.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<ResponseMessage>

A Task whose result is the response message.

SendMessages(IEnumerable<RequestMessage>, MessageEncoderSettings, CancellationToken)

Sends the messages.

void SendMessages(IEnumerable<RequestMessage> messages, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

messages IEnumerable<RequestMessage>

The messages.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

SendMessagesAsync(IEnumerable<RequestMessage>, MessageEncoderSettings, CancellationToken)

Sends the messages.

Task SendMessagesAsync(IEnumerable<RequestMessage> messages, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)

Parameters

messages IEnumerable<RequestMessage>

The messages.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A Task.

SetReadTimeout(TimeSpan)

Set read timeout value.

void SetReadTimeout(TimeSpan timeout)

Parameters

timeout TimeSpan

The timeout.