Dreamine.IO.Fastech.Ethernet 1.0.1
Dreamine.IO.Fastech.Ethernet 산업 자동화 및 I/O 기능을 제공합니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport 클래스 참조sealed

더 자세히 ...

Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport에 대한 상속 다이어그램 :
Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport에 대한 협력 다이어그램:

Public 멤버 함수

 UdpFastechEthernetIoTransport (FastechEthernetIoOptions options)
async Task< IoResult > ConnectAsync (CancellationToken cancellationToken=default)
async Task< IoResult > DisconnectAsync (CancellationToken cancellationToken=default)
async Task< IoResult< byte[]> > SendAndReceiveAsync (IReadOnlyList< byte > requestFrame, int receiveTimeoutMs, int expectedResponseLength, CancellationToken cancellationToken=default)
async ValueTask DisposeAsync ()

속성

bool IsConnected [get]
byte[] LastRequestFrame = [] [get, private set]
byte[] LastResponseFrame = [] [get, private set]

Private 멤버 함수

Task CloseCoreAsync ()
async Task< IPAddress > ResolveRemoteAddressAsync (CancellationToken cancellationToken)
void ThrowIfDisposed ()

정적 Private 멤버 함수

static void DisableUdpConnectionReset (UdpClient client)

Private 속성

readonly SemaphoreSlim _syncLock = new(1, 1)
readonly FastechEthernetIoOptions _options
UdpClient? _udpClient
IPEndPoint? _remoteEndPoint
bool _disposed

상세한 설명

Fastech Ezi-IO Plus-E 통신을 위한 UDP 전송을 제공합니다.

UdpFastechEthernetIoTransport.cs 파일의 16 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ UdpFastechEthernetIoTransport()

Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.UdpFastechEthernetIoTransport ( FastechEthernetIoOptions options)
inline

UdpFastechEthernetIoTransport 클래스의 새 인스턴스를 초기화합니다.

매개변수
optionsFastech Ethernet I/O 연결 옵션입니다.
예외
ArgumentNullExceptionoptionsnull인 경우 발생합니다.

UdpFastechEthernetIoTransport.cs 파일의 88 번째 라인에서 정의되었습니다.

89 {
90 _options = options ?? throw new ArgumentNullException(nameof(options));
91 }

다음을 참조함 : _options.

멤버 함수 문서화

◆ CloseCoreAsync()

Task Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.CloseCoreAsync ( )
inlineprivate

내부 UDP 클라이언트를 닫고 끝점 참조를 초기화합니다.

반환값
완료된 비동기 작업입니다.

UdpFastechEthernetIoTransport.cs 파일의 426 번째 라인에서 정의되었습니다.

427 {
428 _udpClient?.Dispose();
429 _udpClient = null;
430 _remoteEndPoint = null;
431
432 return Task.CompletedTask;
433 }

다음을 참조함 : _remoteEndPoint, _udpClient.

다음에 의해서 참조됨 : ConnectAsync(), DisconnectAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ConnectAsync()

async Task< IoResult > Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.ConnectAsync ( CancellationToken cancellationToken = default)
inline

구성된 원격 끝점을 확인하고 UDP 클라이언트를 준비합니다.

매개변수
cancellationToken연결 준비 취소를 관찰하는 토큰입니다.
반환값
준비 성공 여부와 실패 메시지를 포함한 결과입니다.
예외
OperationCanceledException동기화 잠금을 기다리는 동안 cancellationToken 이 취소된 경우 발생합니다.

Dreamine.IO.Fastech.Ethernet.Transport.IFastechEthernetIoTransport를 구현.

UdpFastechEthernetIoTransport.cs 파일의 155 번째 라인에서 정의되었습니다.

156 {
157 if (string.IsNullOrWhiteSpace(_options.Host))
158 {
159 return IoResult.Failure("The Fastech host must not be empty.");
160 }
161
162 if (_options.Port is <= 0 or > 65535)
163 {
164 return IoResult.Failure($"Invalid UDP port: {_options.Port}.");
165 }
166
167 if (_options.LocalPort is < 0 or > 65535)
168 {
169 return IoResult.Failure($"Invalid local UDP port: {_options.LocalPort}.");
170 }
171
172 await _syncLock.WaitAsync(cancellationToken).ConfigureAwait(false);
173
174 try
175 {
176 ThrowIfDisposed();
177
178 if (IsConnected)
179 {
180 return IoResult.Success();
181 }
182
183 var remoteAddress = await ResolveRemoteAddressAsync(cancellationToken).ConfigureAwait(false);
184 _remoteEndPoint = new IPEndPoint(remoteAddress, _options.Port);
185 _udpClient = _options.LocalPort == 0
186 ? new UdpClient(remoteAddress.AddressFamily)
187 : new UdpClient(_options.LocalPort, remoteAddress.AddressFamily);
188
189 DisableUdpConnectionReset(_udpClient);
190
191 return IoResult.Success();
192 }
193 catch (Exception ex)
194 {
195 await CloseCoreAsync().ConfigureAwait(false);
196 return IoResult.Failure(ex.Message);
197 }
198 finally
199 {
200 _syncLock.Release();
201 }
202 }

다음을 참조함 : _options, _remoteEndPoint, _syncLock, _udpClient, CloseCoreAsync(), DisableUdpConnectionReset(), IsConnected, ResolveRemoteAddressAsync(), ThrowIfDisposed().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ DisableUdpConnectionReset()

void Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.DisableUdpConnectionReset ( UdpClient client)
inlinestaticprivate

Windows에서 ICMP 포트 연결 불가 응답에 따른 UDP 연결 재설정 동작을 비활성화합니다.

매개변수
client설정할 UDP 클라이언트입니다.

UdpFastechEthernetIoTransport.cs 파일의 497 번째 라인에서 정의되었습니다.

498 {
499 if (!OperatingSystem.IsWindows())
500 {
501 return;
502 }
503
504 try
505 {
506 const int sioUdpConnReset = -1744830452;
507 client.Client.IOControl(sioUdpConnReset, [0], null);
508 }
509 catch (SocketException)
510 {
511 }
512 }

다음에 의해서 참조됨 : ConnectAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ DisconnectAsync()

async Task< IoResult > Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.DisconnectAsync ( CancellationToken cancellationToken = default)
inline

현재 UDP 클라이언트와 원격 끝점 정보를 해제합니다.

매개변수
cancellationToken연결 해제 취소를 관찰하는 토큰입니다.
반환값
연결 해제 성공 여부와 실패 메시지를 포함한 결과입니다.
예외
OperationCanceledException동기화 잠금을 기다리는 동안 cancellationToken 이 취소된 경우 발생합니다.

Dreamine.IO.Fastech.Ethernet.Transport.IFastechEthernetIoTransport를 구현.

UdpFastechEthernetIoTransport.cs 파일의 236 번째 라인에서 정의되었습니다.

237 {
238 await _syncLock.WaitAsync(cancellationToken).ConfigureAwait(false);
239
240 try
241 {
242 await CloseCoreAsync().ConfigureAwait(false);
243 return IoResult.Success();
244 }
245 catch (Exception ex)
246 {
247 return IoResult.Failure(ex.Message);
248 }
249 finally
250 {
251 _syncLock.Release();
252 }
253 }

다음을 참조함 : _syncLock, CloseCoreAsync().

다음에 의해서 참조됨 : DisposeAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ DisposeAsync()

async ValueTask Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.DisposeAsync ( )
inline

UDP 클라이언트와 동기화 리소스를 비동기적으로 해제합니다.

반환값
비동기 해제 작업입니다.

UdpFastechEthernetIoTransport.cs 파일의 396 번째 라인에서 정의되었습니다.

397 {
398 if (_disposed)
399 {
400 return;
401 }
402
403 await DisconnectAsync().ConfigureAwait(false);
404 _syncLock.Dispose();
405 _disposed = true;
406
407 GC.SuppressFinalize(this);
408 }

다음을 참조함 : _disposed, _syncLock, DisconnectAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ ResolveRemoteAddressAsync()

async Task< IPAddress > Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.ResolveRemoteAddressAsync ( CancellationToken cancellationToken)
inlineprivate

구성된 호스트 이름 또는 IP 문자열을 원격 IP 주소로 확인합니다.

매개변수
cancellationTokenDNS 조회 취소를 관찰하는 토큰입니다.
반환값
확인된 IPv4 우선 IP 주소입니다.
예외
InvalidOperationException호스트에서 사용할 수 있는 주소를 확인하지 못한 경우 발생합니다.

UdpFastechEthernetIoTransport.cs 파일의 467 번째 라인에서 정의되었습니다.

468 {
469 if (IPAddress.TryParse(_options.Host, out var address))
470 {
471 return address;
472 }
473
474 var addresses = await Dns.GetHostAddressesAsync(_options.Host, cancellationToken).ConfigureAwait(false);
475 var resolvedAddress = addresses.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetwork)
476 ?? addresses.FirstOrDefault();
477
478 return resolvedAddress ?? throw new InvalidOperationException($"Unable to resolve UDP host: {_options.Host}.");
479 }

다음을 참조함 : _options.

다음에 의해서 참조됨 : ConnectAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ SendAndReceiveAsync()

async Task< IoResult< byte[]> > Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.SendAndReceiveAsync ( IReadOnlyList< byte > requestFrame,
int receiveTimeoutMs,
int expectedResponseLength,
CancellationToken cancellationToken = default )
inline

요청 데이터그램을 보내고 하나의 UDP 응답 데이터그램을 받습니다.

매개변수
requestFrame전송할 요청 바이트입니다.
receiveTimeoutMs밀리초 단위의 수신 제한 시간입니다.
expectedResponseLength인터페이스 호환성을 위한 기대 응답 길이이며 UDP에서는 사용하지 않습니다.
cancellationToken송수신 취소를 관찰하는 토큰입니다.
반환값
수신 데이터그램 또는 실패 메시지를 포함한 결과입니다.
예외
ArgumentNullExceptionrequestFramenull인 경우 발생합니다.
OperationCanceledException동기화 잠금을 기다리는 동안 cancellationToken 이 취소된 경우 발생합니다.

Dreamine.IO.Fastech.Ethernet.Transport.IFastechEthernetIoTransport를 구현.

UdpFastechEthernetIoTransport.cs 파일의 319 번째 라인에서 정의되었습니다.

324 {
325 ArgumentNullException.ThrowIfNull(requestFrame);
326
327 if (requestFrame.Count == 0)
328 {
329 return IoResult<byte[]>.Failure("The request frame must not be empty.");
330 }
331
332 if (receiveTimeoutMs <= 0)
333 {
334 return IoResult<byte[]>.Failure("The receive timeout must be greater than zero.");
335 }
336
337 await _syncLock.WaitAsync(cancellationToken).ConfigureAwait(false);
338
339 try
340 {
341 ThrowIfDisposed();
342
343 if (_udpClient is null || _remoteEndPoint is null)
344 {
345 return IoResult<byte[]>.Failure("The Fastech UDP transport is not connected.");
346 }
347
348 var requestBuffer = requestFrame as byte[] ?? requestFrame.ToArray();
349 LastRequestFrame = requestBuffer;
350 LastResponseFrame = [];
351
352 using var timeoutCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
353 timeoutCts.CancelAfter(receiveTimeoutMs);
354
355 await _udpClient.SendAsync(requestBuffer, _remoteEndPoint, timeoutCts.Token).ConfigureAwait(false);
356 var response = await _udpClient.ReceiveAsync(timeoutCts.Token).ConfigureAwait(false);
357 LastResponseFrame = response.Buffer;
358
359 return IoResult<byte[]>.Success(response.Buffer);
360 }
361 catch (OperationCanceledException ex)
362 {
363 return IoResult<byte[]>.Failure($"No UDP response from {_options.Host}:{_options.Port} within {receiveTimeoutMs} ms. {ex.Message}");
364 }
365 catch (SocketException ex) when (ex.SocketErrorCode == SocketError.ConnectionReset)
366 {
367 return IoResult<byte[]>.Failure(
368 $"No UDP listener responded at {_options.Host}:{_options.Port}. Windows reported UDP reset/ICMP port unreachable. {ex.Message}");
369 }
370 catch (Exception ex)
371 {
372 return IoResult<byte[]>.Failure(ex.Message);
373 }
374 finally
375 {
376 _syncLock.Release();
377 }
378 }

다음을 참조함 : _remoteEndPoint, _syncLock, _udpClient, LastRequestFrame, LastResponseFrame, ThrowIfDisposed().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ ThrowIfDisposed()

void Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.ThrowIfDisposed ( )
inlineprivate

이 전송 객체가 이미 해제되었으면 예외를 발생시킵니다.

예외
ObjectDisposedException객체가 이미 해제된 경우 발생합니다.

UdpFastechEthernetIoTransport.cs 파일의 530 번째 라인에서 정의되었습니다.

531 {
532 ObjectDisposedException.ThrowIf(_disposed, this);
533 }

다음을 참조함 : _disposed.

다음에 의해서 참조됨 : ConnectAsync(), SendAndReceiveAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ _disposed

bool Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport._disposed
private

disposed 값을 보관합니다.

UdpFastechEthernetIoTransport.cs 파일의 62 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : DisposeAsync(), ThrowIfDisposed().

◆ _options

readonly FastechEthernetIoOptions Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport._options
private

options 값을 보관합니다.

UdpFastechEthernetIoTransport.cs 파일의 35 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ConnectAsync(), ResolveRemoteAddressAsync(), UdpFastechEthernetIoTransport().

◆ _remoteEndPoint

IPEndPoint? Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport._remoteEndPoint
private

remote End Point 값을 보관합니다.

UdpFastechEthernetIoTransport.cs 파일의 53 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : CloseCoreAsync(), ConnectAsync(), SendAndReceiveAsync().

◆ _syncLock

readonly SemaphoreSlim Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport._syncLock = new(1, 1)
private

sync Lock 값을 보관합니다.

UdpFastechEthernetIoTransport.cs 파일의 26 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ConnectAsync(), DisconnectAsync(), DisposeAsync(), SendAndReceiveAsync().

◆ _udpClient

UdpClient? Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport._udpClient
private

udp Client 값을 보관합니다.

UdpFastechEthernetIoTransport.cs 파일의 44 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : CloseCoreAsync(), ConnectAsync(), SendAndReceiveAsync().

속성 문서화

◆ IsConnected

bool Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.IsConnected
get

UDP 클라이언트가 생성되어 있는지 여부를 가져옵니다.

Dreamine.IO.Fastech.Ethernet.Transport.IFastechEthernetIoTransport를 구현.

UdpFastechEthernetIoTransport.cs 파일의 101 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ConnectAsync().

◆ LastRequestFrame

byte [] Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.LastRequestFrame = []
getprivate set

이 전송에서 마지막으로 보낸 요청 프레임을 가져옵니다.

UdpFastechEthernetIoTransport.cs 파일의 111 번째 라인에서 정의되었습니다.

111{ get; private set; } = [];

다음에 의해서 참조됨 : SendAndReceiveAsync().

◆ LastResponseFrame

byte [] Dreamine.IO.Fastech.Ethernet.Transport.UdpFastechEthernetIoTransport.LastResponseFrame = []
getprivate set

이 전송에서 마지막으로 받은 응답 프레임을 가져옵니다.

UdpFastechEthernetIoTransport.cs 파일의 121 번째 라인에서 정의되었습니다.

121{ get; private set; } = [];

다음에 의해서 참조됨 : SendAndReceiveAsync().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: