mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-21 04:03:05 +08:00
Add new options.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
// The .NET Foundation licenses this file to you under the MIT license.
|
// The .NET Foundation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
|
||||||
namespace MQTTnet.Client
|
namespace MQTTnet.Client
|
||||||
@@ -10,6 +11,12 @@ namespace MQTTnet.Client
|
|||||||
{
|
{
|
||||||
public AddressFamily AddressFamily { get; set; } = AddressFamily.Unspecified;
|
public AddressFamily AddressFamily { get; set; } = AddressFamily.Unspecified;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the local endpoint (network card) which is used by the client.
|
||||||
|
/// Set it to _null_ to let the OS select the network card.
|
||||||
|
/// </summary>
|
||||||
|
public EndPoint LocalEndpoint { get; set; }
|
||||||
|
|
||||||
public int BufferSize { get; set; } = 8192;
|
public int BufferSize { get; set; } = 8192;
|
||||||
|
|
||||||
public bool? DualMode { get; set; }
|
public bool? DualMode { get; set; }
|
||||||
|
|||||||
@@ -68,6 +68,11 @@ namespace MQTTnet.Implementations
|
|||||||
socket = new CrossPlatformSocket(_tcpOptions.AddressFamily);
|
socket = new CrossPlatformSocket(_tcpOptions.AddressFamily);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_tcpOptions.LocalEndpoint != null)
|
||||||
|
{
|
||||||
|
socket.Bind(_tcpOptions.LocalEndpoint);
|
||||||
|
}
|
||||||
|
|
||||||
socket.ReceiveBufferSize = _tcpOptions.BufferSize;
|
socket.ReceiveBufferSize = _tcpOptions.BufferSize;
|
||||||
socket.SendBufferSize = _tcpOptions.BufferSize;
|
socket.SendBufferSize = _tcpOptions.BufferSize;
|
||||||
socket.SendTimeout = (int)_clientOptions.Timeout.TotalMilliseconds;
|
socket.SendTimeout = (int)_clientOptions.Timeout.TotalMilliseconds;
|
||||||
|
|||||||
Reference in New Issue
Block a user