< Summary

Information
Class: IceRpc.Transports.Tcp.TcpServerTransportOptions
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Transports/Tcp/TcpTransportOptions.cs
Tag: 275_13775359185
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 70
Line coverage: 100%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage
100%
Covered methods: 3
Total methods: 3
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ListenBacklog()100%11100%
set_ListenBacklog(...)50%22100%
.ctor()100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Transports/Tcp/TcpTransportOptions.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Net;
 4
 5namespace IceRpc.Transports.Tcp;
 6
 7/// <summary>The base options class for TCP transports.</summary>
 8public record class TcpTransportOptions
 9{
 10    /// <summary>Gets or sets a value indicating whether the underlying socket is using the Nagle algorithm.
 11    /// </summary>
 12    /// <value><see langword="false" /> if the socket uses the Nagle algorithm; otherwise, <see langword="true" />.
 13    /// Defaults to <see langword="true" />.</value>
 14    public bool NoDelay { get; set; } = true;
 15
 16    /// <summary>Gets or sets the socket receive buffer size in bytes.</summary>
 17    /// <value>The receive buffer size in bytes. It can't be less than <c>1</c> KB. <see langword="null" /> means use
 18    /// the operating system default. Defaults to <see langword="null" />.</value>
 19    public int? ReceiveBufferSize
 20    {
 21        get => _receiveBufferSize;
 22        set => _receiveBufferSize = value is null || value >= 1024 ? value :
 23            throw new ArgumentException(
 24                $"The {nameof(ReceiveBufferSize)} value cannot be less than 1KB.",
 25                nameof(value));
 26    }
 27
 28    /// <summary>Gets or sets the socket send buffer size in bytes.</summary>
 29    /// <value>The send buffer size in bytes. It can't be less than <c>1</c> KB. <see langword="null" /> means use the
 30    /// OS default. Defaults to <see langword="null" />.
 31    /// </value>
 32    public int? SendBufferSize
 33    {
 34        get => _sendBufferSize;
 35        set => _sendBufferSize = value is null || value >= 1024 ? value :
 36            throw new ArgumentException(
 37                $"The {nameof(SendBufferSize)} value cannot be less than 1KB.",
 38                nameof(value));
 39    }
 40
 41    private int? _receiveBufferSize;
 42    private int? _sendBufferSize;
 43}
 44
 45/// <summary>The options class for configuring <see cref="TcpClientTransport" />.</summary>
 46public sealed record class TcpClientTransportOptions : TcpTransportOptions
 47{
 48    /// <summary>Gets or sets the address and port represented by a .NET <see cref="IPEndPoint"/> to use for a client
 49    /// socket. If specified the client socket will bind to this address and port before connection establishment.
 50    /// </summary>
 51    /// <value>The address and port to bind the socket to. Defaults to <see langword="null" />.</value>
 52    public IPEndPoint? LocalNetworkAddress { get; set; }
 53}
 54
 55/// <summary>The options class for configuring <see cref="TcpServerTransport" />.</summary>
 56public sealed record class TcpServerTransportOptions : TcpTransportOptions
 57{
 58    /// <summary>Gets or sets the length of the server socket queue for accepting new connections. If a new connection
 59    /// request arrives and the queue is full, the client connection establishment will fail with a <see
 60    /// cref="IceRpcException" /> and the <see cref="IceRpcError.ConnectionRefused" /> error code.</summary>
 61    /// <value>The server socket backlog size. Defaults to <c>511</c>.</value>
 62    public int ListenBacklog
 63    {
 23064        get => _listenBacklog;
 1465        set => _listenBacklog = value > 0 ? value :
 1466            throw new ArgumentException($"The {nameof(ListenBacklog)} value cannot be less than 1", nameof(value));
 67    }
 68
 24169    private int _listenBacklog = 511;
 70}