mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 03:24:33 +08:00
Additional performance improvements
This commit is contained in:
@@ -46,7 +46,7 @@ namespace MQTTnet.Implementations
|
||||
_socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
|
||||
}
|
||||
|
||||
await Task.Factory.FromAsync(_socket.BeginConnect, _socket.EndConnect, options.Server, options.GetPort(), null);
|
||||
await Task.Factory.FromAsync(_socket.BeginConnect, _socket.EndConnect, options.Server, options.GetPort(), null).ConfigureAwait(false);
|
||||
|
||||
if (options.TlsOptions.UseTls)
|
||||
{
|
||||
@@ -99,12 +99,11 @@ namespace MQTTnet.Implementations
|
||||
|
||||
try
|
||||
{
|
||||
int totalBytes = 0;
|
||||
var totalBytes = 0;
|
||||
|
||||
do
|
||||
{
|
||||
var read = await _dataStream.ReadAsync(buffer, totalBytes, buffer.Length - totalBytes).ConfigureAwait(false);
|
||||
|
||||
if (read == 0)
|
||||
{
|
||||
throw new MqttCommunicationException(new SocketException((int)SocketError.Disconnecting));
|
||||
|
||||
Reference in New Issue
Block a user