From b9a73cc23dad056390ce3d1ca7299e980cebb072 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 28 Apr 2018 13:05:35 +0200 Subject: [PATCH] Changed socket features. --- .../Implementations/MqttTcpChannel.Uwp.cs | 1 + .../Implementations/MqttTcpServerAdapter.Uwp.cs | 7 +++++-- .../Implementations/MqttTcpServerAdapter.cs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.Uwp.cs b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.Uwp.cs index 41e1d54..19d5824 100644 --- a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.Uwp.cs +++ b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpChannel.Uwp.cs @@ -49,6 +49,7 @@ namespace MQTTnet.Implementations { _socket = new StreamSocket(); _socket.Control.NoDelay = true; + _socket.Control.KeepAlive = true; } if (!_options.TlsOptions.UseTls) diff --git a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpServerAdapter.Uwp.cs b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpServerAdapter.Uwp.cs index aba092a..b2c3110 100644 --- a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpServerAdapter.Uwp.cs +++ b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpServerAdapter.Uwp.cs @@ -33,9 +33,12 @@ namespace MQTTnet.Implementations // This also affects the client sockets. _defaultEndpointSocket.Control.NoDelay = true; + _defaultEndpointSocket.Control.KeepAlive = true; + _defaultEndpointSocket.Control.QualityOfService = SocketQualityOfService.LowLatency; + _defaultEndpointSocket.ConnectionReceived += AcceptDefaultEndpointConnectionsAsync; await _defaultEndpointSocket.BindServiceNameAsync(options.GetDefaultEndpointPort().ToString(), SocketProtectionLevel.PlainSocket); - _defaultEndpointSocket.ConnectionReceived += AcceptDefaultEndpointConnectionsAsync; + } if (options.TlsEndpointOptions.IsEnabled) @@ -59,7 +62,7 @@ namespace MQTTnet.Implementations public void Dispose() { - StopAsync(); + StopAsync().GetAwaiter().GetResult(); } private void AcceptDefaultEndpointConnectionsAsync(StreamSocketListener sender, StreamSocketListenerConnectionReceivedEventArgs args) diff --git a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpServerAdapter.cs b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpServerAdapter.cs index 56457b5..f1d349d 100644 --- a/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpServerAdapter.cs +++ b/Frameworks/MQTTnet.NetStandard/Implementations/MqttTcpServerAdapter.cs @@ -88,7 +88,7 @@ namespace MQTTnet.Implementations public void Dispose() { - StopAsync(); + StopAsync().GetAwaiter().GetResult(); } private async Task AcceptDefaultEndpointConnectionsAsync(CancellationToken cancellationToken)