Skip to content

Commit

Permalink
Changed socket features.
Browse files Browse the repository at this point in the history
  • Loading branch information
chkr1011 committed Apr 28, 2018
1 parent 357fd84 commit b9a73cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public async Task ConnectAsync(CancellationToken cancellationToken)
{
_socket = new StreamSocket();
_socket.Control.NoDelay = true;
_socket.Control.KeepAlive = true;
}

if (!_options.TlsOptions.UseTls)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ public async Task StartAsync(IMqttServerOptions options)

// 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)
Expand All @@ -59,7 +62,7 @@ public Task StopAsync()

public void Dispose()
{
StopAsync();
StopAsync().GetAwaiter().GetResult();
}

private void AcceptDefaultEndpointConnectionsAsync(StreamSocketListener sender, StreamSocketListenerConnectionReceivedEventArgs args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Task StopAsync()

public void Dispose()
{
StopAsync();
StopAsync().GetAwaiter().GetResult();
}

private async Task AcceptDefaultEndpointConnectionsAsync(CancellationToken cancellationToken)
Expand Down

0 comments on commit b9a73cc

Please sign in to comment.