diff --git a/S7.Net/PLC.cs b/S7.Net/PLC.cs index 3a73b4c..b7ede94 100644 --- a/S7.Net/PLC.cs +++ b/S7.Net/PLC.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Net.Sockets; using S7.Net.Protocol; @@ -242,6 +243,16 @@ namespace S7.Net } } + private Stream GetStreamIfAvailable() + { + if (_stream == null) + { + throw new PlcException(ErrorCode.ConnectionError, "Plc is not connected"); + } + + return _stream; + } + #region IDisposable Support private bool disposedValue = false; // To detect redundant calls diff --git a/S7.Net/PlcAsynchronous.cs b/S7.Net/PlcAsynchronous.cs index 7730b3a..3e523d8 100644 --- a/S7.Net/PlcAsynchronous.cs +++ b/S7.Net/PlcAsynchronous.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Net.Sockets; using System.Threading.Tasks; using S7.Net.Protocol; -using System.IO; using System.Threading; using S7.Net.Protocol.S7; @@ -502,15 +501,6 @@ namespace S7.Net } } - private Stream GetStreamIfAvailable() - { - if (_stream == null) - { - throw new PlcException(ErrorCode.ConnectionError, "Plc is not connected"); - } - return _stream; - } - private async Task RequestTpduAsync(byte[] requestData, CancellationToken cancellationToken = default) { var stream = GetStreamIfAvailable();