• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Interface ITextProtocolTransport

Abstracts a line-oriented text protocol wire (TCP + optional TLS). All socket I/O in SmtpClient, Pop3Client, and ImapClient goes through this interface so that unit tests can inject an in-process transport without a real socket.

Inherited Members
IDisposable.Dispose()
Namespace: DRIT.Mail.Rfc.Net.Transport
Assembly: DRIT.Mail.dll
Syntax
public interface ITextProtocolTransport : IDisposable

Properties

View Source

IsConnected

Gets a value indicating whether the transport is connected.

Declaration
bool IsConnected { get; }
Property Value
Type Description
bool
View Source

IsEncrypted

Gets a value indicating whether the transport is encrypted (TLS).

Declaration
bool IsEncrypted { get; }
Property Value
Type Description
bool

Methods

View Source

Close()

Closes the transport. Safe to call multiple times.

Declaration
void Close()
View Source

Connect(string, int, TimeSpan)

Connects to the specified host and port.

Declaration
void Connect(string host, int port, TimeSpan timeout)
Parameters
Type Name Description
string host

The server hostname.

int port

The server port.

TimeSpan timeout

The connection timeout.

View Source

Connect(string, int, TimeSpan, bool, RemoteCertificateValidationCallback?)

Connects to the specified host and port, optionally using implicit TLS from the moment of TCP connect.

Declaration
void Connect(string host, int port, TimeSpan timeout, bool useImplicitTls, RemoteCertificateValidationCallback? validationCallback)
Parameters
Type Name Description
string host

The remote host name or address.

int port

The remote service port.

TimeSpan timeout

The connection timeout.

bool useImplicitTls

A value indicating whether TLS starts immediately after connecting.

RemoteCertificateValidationCallback validationCallback

Optional certificate validation callback for the TLS handshake.

View Source

Flush()

Flushes any buffered write data.

Declaration
void Flush()
View Source

ReadBytes(int)

Reads exactly count bytes from the transport. Used by IMAP for literal {N} data blocks.

Declaration
byte[] ReadBytes(int count)
Parameters
Type Name Description
int count

The number of bytes to read.

Returns
Type Description
byte[]

The bytes read.

View Source

ReadLine()

Reads one CRLF-terminated line from the transport.

Declaration
byte[]? ReadLine()
Returns
Type Description
byte[]

The line content (without the trailing CRLF) as bytes, or null if the connection was closed and no data remains.

View Source

UpgradeToSsl(string, RemoteCertificateValidationCallback?)

Upgrades the current connection to TLS (STARTTLS / STLS).

Declaration
void UpgradeToSsl(string host, RemoteCertificateValidationCallback? validationCallback)
Parameters
Type Name Description
string host

The server hostname, used for certificate validation.

RemoteCertificateValidationCallback validationCallback

Optional certificate validation callback, or null to use the platform default.

View Source

Write(byte[])

Writes all bytes in the buffer to the transport.

Declaration
void Write(byte[] buffer)
Parameters
Type Name Description
byte[] buffer

The byte data to process.

View Source

Write(byte[], int, int)

Writes a range of bytes to the transport.

Declaration
void Write(byte[] buffer, int offset, int count)
Parameters
Type Name Description
byte[] buffer

The byte data to process.

int offset

The offset within the data.

int count

The count value.

  • View Source
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX