Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Ping.cs
Go to the documentation of this file.
8
10
11public class Ping : Component
12{
13 private readonly ManualResetEventSlim _lockObject = new ManualResetEventSlim(initialState: true);
14
15 private SendOrPostCallback _onPingCompletedDelegate;
16
17 private bool _disposeRequested;
18
19 private byte[] _defaultSendBuffer;
20
21 private bool _canceled;
22
23 private int _status;
24
25 private static readonly SafeWaitHandle s_nullSafeWaitHandle = new SafeWaitHandle(IntPtr.Zero, ownsHandle: true);
26
27 private int _sendSize;
28
29 private bool _ipv6;
30
32
34
36
38
39 private global::Interop.IpHlpApi.SafeCloseIcmpHandle _handlePingV4;
40
41 private global::Interop.IpHlpApi.SafeCloseIcmpHandle _handlePingV6;
42
44
45 private byte[] DefaultSendBuffer
46 {
47 get
48 {
49 if (_defaultSendBuffer == null)
50 {
51 _defaultSendBuffer = new byte[32];
52 for (int i = 0; i < 32; i++)
53 {
54 _defaultSendBuffer[i] = (byte)(97 + i % 23);
55 }
56 }
57 return _defaultSendBuffer;
58 }
59 }
60
62
63 public Ping()
64 {
65 if (GetType() == typeof(Ping))
66 {
67 GC.SuppressFinalize(this);
68 }
69 }
70
71 private void CheckArgs(int timeout, byte[] buffer, PingOptions options)
72 {
74 if (buffer == null)
75 {
76 throw new ArgumentNullException("buffer");
77 }
78 if (buffer.Length > 65500)
79 {
81 }
82 if (timeout < 0)
83 {
84 throw new ArgumentOutOfRangeException("timeout");
85 }
86 }
87
88 private void CheckArgs(IPAddress address, int timeout, byte[] buffer, PingOptions options)
89 {
91 if (address == null)
92 {
93 throw new ArgumentNullException("address");
94 }
95 TestIsIpSupported(address);
96 if (address.Equals(IPAddress.Any) || address.Equals(IPAddress.IPv6Any))
97 {
98 throw new ArgumentException(System.SR.net_invalid_ip_addr, "address");
99 }
100 }
101
102 private void CheckDisposed()
103 {
105 {
106 throw new ObjectDisposedException(GetType().FullName);
107 }
108 }
109
110 private void CheckStart()
111 {
112 int status;
113 lock (_lockObject)
114 {
115 status = _status;
116 if (status == 0)
117 {
118 _canceled = false;
119 _status = 1;
121 return;
122 }
123 }
124 if (status == 1)
125 {
127 }
128 throw new ObjectDisposedException(GetType().FullName);
129 }
130
131 private static IPAddress GetAddressSnapshot(IPAddress address)
132 {
133 return (address.AddressFamily == AddressFamily.InterNetwork) ? new IPAddress(address.Address) : new IPAddress(address.GetAddressBytes(), address.ScopeId);
134 }
135
136 private void Finish()
137 {
138 lock (_lockObject)
139 {
140 _status = 0;
142 }
144 {
146 }
147 }
148
149 private void InternalDispose()
150 {
151 _disposeRequested = true;
152 lock (_lockObject)
153 {
154 if (_status != 0)
155 {
156 return;
157 }
158 _status = 2;
159 }
161 }
162
163 protected override void Dispose(bool disposing)
164 {
165 if (disposing)
166 {
168 }
169 }
170
172 {
173 this.PingCompleted?.Invoke(this, e);
174 }
175
176 public PingReply Send(string hostNameOrAddress)
177 {
178 return Send(hostNameOrAddress, 5000, DefaultSendBuffer);
179 }
180
181 public PingReply Send(string hostNameOrAddress, int timeout)
182 {
183 return Send(hostNameOrAddress, timeout, DefaultSendBuffer);
184 }
185
186 public PingReply Send(IPAddress address)
187 {
188 return Send(address, 5000, DefaultSendBuffer);
189 }
190
191 public PingReply Send(IPAddress address, int timeout)
192 {
193 return Send(address, timeout, DefaultSendBuffer);
194 }
195
196 public PingReply Send(string hostNameOrAddress, int timeout, byte[] buffer)
197 {
198 return Send(hostNameOrAddress, timeout, buffer, null);
199 }
200
201 public PingReply Send(IPAddress address, int timeout, byte[] buffer)
202 {
203 return Send(address, timeout, buffer, null);
204 }
205
206 public PingReply Send(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions? options)
207 {
208 if (string.IsNullOrEmpty(hostNameOrAddress))
209 {
210 throw new ArgumentNullException("hostNameOrAddress");
211 }
212 if (IPAddress.TryParse(hostNameOrAddress, out IPAddress address))
213 {
214 return Send(address, timeout, buffer, options);
215 }
217 return GetAddressAndSend(hostNameOrAddress, timeout, buffer, options);
218 }
219
220 public PingReply Send(IPAddress address, int timeout, byte[] buffer, PingOptions? options)
221 {
222 CheckArgs(address, timeout, buffer, options);
223 IPAddress addressSnapshot = GetAddressSnapshot(address);
224 CheckStart();
225 try
226 {
227 return SendPingCore(addressSnapshot, buffer, timeout, options);
228 }
229 catch (Exception innerException)
230 {
231 throw new PingException(System.SR.net_ping, innerException);
232 }
233 finally
234 {
235 Finish();
236 }
237 }
238
239 public void SendAsync(string hostNameOrAddress, object? userToken)
240 {
241 SendAsync(hostNameOrAddress, 5000, DefaultSendBuffer, userToken);
242 }
243
244 public void SendAsync(string hostNameOrAddress, int timeout, object? userToken)
245 {
246 SendAsync(hostNameOrAddress, timeout, DefaultSendBuffer, userToken);
247 }
248
249 public void SendAsync(IPAddress address, object? userToken)
250 {
251 SendAsync(address, 5000, DefaultSendBuffer, userToken);
252 }
253
254 public void SendAsync(IPAddress address, int timeout, object? userToken)
255 {
256 SendAsync(address, timeout, DefaultSendBuffer, userToken);
257 }
258
259 public void SendAsync(string hostNameOrAddress, int timeout, byte[] buffer, object? userToken)
260 {
261 SendAsync(hostNameOrAddress, timeout, buffer, null, userToken);
262 }
263
264 public void SendAsync(IPAddress address, int timeout, byte[] buffer, object? userToken)
265 {
266 SendAsync(address, timeout, buffer, null, userToken);
267 }
268
269 public void SendAsync(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions? options, object? userToken)
270 {
271 TranslateTaskToEap(userToken, SendPingAsync(hostNameOrAddress, timeout, buffer, options));
272 }
273
274 public void SendAsync(IPAddress address, int timeout, byte[] buffer, PingOptions? options, object? userToken)
275 {
276 TranslateTaskToEap(userToken, SendPingAsync(address, timeout, buffer, options));
277 }
278
279 private void TranslateTaskToEap(object userToken, Task<PingReply> pingTask)
280 {
281 pingTask.ContinueWith(delegate(Task<PingReply> t, object state)
282 {
283 AsyncOperation asyncOperation = (AsyncOperation)state;
285 SendOrPostCallback d = delegate(object o)
286 {
288 };
289 asyncOperation.PostOperationCompleted(d, arg);
291 }
292
294 {
295 return SendPingAsync(address, 5000, DefaultSendBuffer, null);
296 }
297
298 public Task<PingReply> SendPingAsync(string hostNameOrAddress)
299 {
300 return SendPingAsync(hostNameOrAddress, 5000, DefaultSendBuffer, null);
301 }
302
304 {
305 return SendPingAsync(address, timeout, DefaultSendBuffer, null);
306 }
307
308 public Task<PingReply> SendPingAsync(string hostNameOrAddress, int timeout)
309 {
310 return SendPingAsync(hostNameOrAddress, timeout, DefaultSendBuffer, null);
311 }
312
314 {
315 return SendPingAsync(address, timeout, buffer, null);
316 }
317
318 public Task<PingReply> SendPingAsync(string hostNameOrAddress, int timeout, byte[] buffer)
319 {
320 return SendPingAsync(hostNameOrAddress, timeout, buffer, null);
321 }
322
324 {
325 CheckArgs(address, timeout, buffer, options);
326 return SendPingAsyncInternal(address, timeout, buffer, options);
327 }
328
330 {
331 IPAddress addressSnapshot = GetAddressSnapshot(address);
332 CheckStart();
333 try
334 {
336 return await task.ConfigureAwait(continueOnCapturedContext: false);
337 }
338 catch (Exception innerException)
339 {
340 throw new PingException(System.SR.net_ping, innerException);
341 }
342 finally
343 {
344 Finish();
345 }
346 }
347
348 public Task<PingReply> SendPingAsync(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions? options)
349 {
350 if (string.IsNullOrEmpty(hostNameOrAddress))
351 {
352 throw new ArgumentNullException("hostNameOrAddress");
353 }
354 if (IPAddress.TryParse(hostNameOrAddress, out IPAddress address))
355 {
356 return SendPingAsync(address, timeout, buffer, options);
357 }
359 return GetAddressAndSendAsync(hostNameOrAddress, timeout, buffer, options);
360 }
361
362 public void SendAsyncCancel()
363 {
364 lock (_lockObject)
365 {
366 if (!_lockObject.IsSet)
367 {
368 _canceled = true;
369 }
370 }
372 }
373
374 private PingReply GetAddressAndSend(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions options)
375 {
376 CheckStart();
377 try
378 {
379 IPAddress[] hostAddresses = Dns.GetHostAddresses(hostNameOrAddress);
380 return SendPingCore(hostAddresses[0], buffer, timeout, options);
381 }
382 catch (Exception innerException)
383 {
384 throw new PingException(System.SR.net_ping, innerException);
385 }
386 finally
387 {
388 Finish();
389 }
390 }
391
392 private async Task<PingReply> GetAddressAndSendAsync(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions options)
393 {
394 CheckStart();
395 try
396 {
397 Task<PingReply> task = SendPingAsyncCore((await Dns.GetHostAddressesAsync(hostNameOrAddress).ConfigureAwait(continueOnCapturedContext: false))[0], buffer, timeout, options);
398 return await task.ConfigureAwait(continueOnCapturedContext: false);
399 }
400 catch (Exception innerException)
401 {
402 throw new PingException(System.SR.net_ping, innerException);
403 }
404 finally
405 {
406 Finish();
407 }
408 }
409
421
422 private void InternalDisposeCore()
423 {
424 if (_handlePingV4 != null)
425 {
426 _handlePingV4.Dispose();
427 _handlePingV4 = null;
428 }
429 if (_handlePingV6 != null)
430 {
431 _handlePingV6.Dispose();
432 _handlePingV6 = null;
433 }
435 if (_pingEvent != null)
436 {
438 _pingEvent = null;
439 }
440 if (_replyBuffer != null)
441 {
443 _replyBuffer = null;
444 }
445 }
446
448 {
449 return DoSendPingCore(address, buffer, timeout, options, isAsync: false).GetAwaiter().GetResult();
450 }
451
453 {
454 return DoSendPingCore(address, buffer, timeout, options, isAsync: true);
455 }
456
457 private Task<PingReply> DoSendPingCore(IPAddress address, byte[] buffer, int timeout, PingOptions options, bool isAsync)
458 {
459 TaskCompletionSource<PingReply> taskCompletionSource = null;
460 if (isAsync)
461 {
462 taskCompletionSource = (_taskCompletionSource = new TaskCompletionSource<PingReply>());
463 }
464 _ipv6 = address.AddressFamily == AddressFamily.InterNetworkV6;
465 _sendSize = buffer.Length;
467 if (_replyBuffer == null)
468 {
470 }
471 int num;
472 try
473 {
474 if (isAsync)
475 {
477 }
479 num = SendEcho(address, buffer, timeout, options, isAsync);
480 }
481 catch
482 {
483 Cleanup(isAsync);
484 throw;
485 }
486 if (num == 0)
487 {
489 if (!isAsync || (long)num != 997)
490 {
491 Cleanup(isAsync);
492 IPStatus statusFromCode = GetStatusFromCode(num);
493 return Task.FromResult(new PingReply(address, null, statusFromCode, 0L, Array.Empty<byte>()));
494 }
495 }
496 if (taskCompletionSource != null)
497 {
498 return taskCompletionSource.Task;
499 }
500 Cleanup(isAsync);
501 return Task.FromResult(CreatePingReply());
502 }
503
504 private void RegisterWaitHandle()
505 {
506 if (_pingEvent == null)
507 {
508 _pingEvent = new ManualResetEvent(initialState: false);
509 }
510 else
511 {
513 }
515 {
516 ((Ping)state).PingCallback();
517 }, this, -1, executeOnlyOnce: true);
518 }
519
520 private void UnregisterWaitHandle()
521 {
522 lock (_lockObject)
523 {
524 if (_registeredWait != null)
525 {
527 _registeredWait = null;
528 }
529 }
530 }
531
532 private SafeWaitHandle GetWaitHandle(bool async)
533 {
534 if (async)
535 {
536 return _pingEvent.GetSafeWaitHandle();
537 }
539 }
540
541 private void InitialiseIcmpHandle()
542 {
543 if (!_ipv6 && _handlePingV4 == null)
544 {
545 _handlePingV4 = global::Interop.IpHlpApi.IcmpCreateFile();
546 if (_handlePingV4.IsInvalid)
547 {
548 _handlePingV4 = null;
549 throw new Win32Exception();
550 }
551 }
552 else if (_ipv6 && _handlePingV6 == null)
553 {
554 _handlePingV6 = global::Interop.IpHlpApi.Icmp6CreateFile();
555 if (_handlePingV6.IsInvalid)
556 {
557 _handlePingV6 = null;
558 throw new Win32Exception();
559 }
560 }
561 }
562
563 private int SendEcho(IPAddress address, byte[] buffer, int timeout, PingOptions options, bool isAsync)
564 {
565 global::Interop.IpHlpApi.IPOptions options2 = new global::Interop.IpHlpApi.IPOptions(options);
566 if (!_ipv6)
567 {
568 return (int)global::Interop.IpHlpApi.IcmpSendEcho2(_handlePingV4, GetWaitHandle(isAsync), IntPtr.Zero, IntPtr.Zero, (uint)address.Address, _requestBuffer, (ushort)buffer.Length, ref options2, _replyBuffer, 65791u, (uint)timeout);
569 }
570 IPEndPoint endpoint = new IPEndPoint(address, 0);
572 byte[] sourceSocketAddress = new byte[28];
573 return (int)global::Interop.IpHlpApi.Icmp6SendEcho2(_handlePingV6, GetWaitHandle(isAsync), IntPtr.Zero, IntPtr.Zero, sourceSocketAddress, socketAddress.Buffer, _requestBuffer, (ushort)buffer.Length, ref options2, _replyBuffer, 65791u, (uint)timeout);
574 }
575
577 {
579 if (_ipv6)
580 {
581 global::Interop.IpHlpApi.Icmp6EchoReply reply = Marshal.PtrToStructure<global::Interop.IpHlpApi.Icmp6EchoReply>(replyBuffer.DangerousGetHandle());
583 }
584 global::Interop.IpHlpApi.IcmpEchoReply reply2 = Marshal.PtrToStructure<global::Interop.IpHlpApi.IcmpEchoReply>(replyBuffer.DangerousGetHandle());
586 }
587
588 private void Cleanup(bool isAsync)
589 {
591 if (isAsync)
592 {
594 }
595 }
596
597 private void PingCallback()
598 {
601 PingReply pingReply = null;
602 Exception exception = null;
603 bool flag = false;
604 try
605 {
606 lock (_lockObject)
607 {
608 flag = _canceled;
609 pingReply = CreatePingReply();
610 }
611 }
612 catch (Exception innerException)
613 {
614 exception = new PingException(System.SR.net_ping, innerException);
615 }
616 finally
617 {
618 Cleanup(isAsync: true);
619 }
620 if (flag)
621 {
622 taskCompletionSource.SetCanceled();
623 }
624 else if (pingReply != null)
625 {
626 taskCompletionSource.SetResult(pingReply);
627 }
628 else
629 {
630 taskCompletionSource.SetException(exception);
631 }
632 }
633
634 private unsafe void SetUnmanagedStructures(byte[] buffer)
635 {
637 byte* ptr = (byte*)(void*)_requestBuffer.DangerousGetHandle();
638 for (int i = 0; i < buffer.Length; i++)
639 {
640 ptr[i] = buffer[i];
641 }
642 }
643
645 {
646 if (_requestBuffer != null)
647 {
649 _requestBuffer = null;
650 }
651 }
652
653 private static IPStatus GetStatusFromCode(int statusCode)
654 {
655 if (statusCode != 0 && statusCode < 11000)
656 {
657 throw new Win32Exception(statusCode);
658 }
659 return (IPStatus)statusCode;
660 }
661
662 private static PingReply CreatePingReplyFromIcmpEchoReply(global::Interop.IpHlpApi.IcmpEchoReply reply)
663 {
664 IPAddress address = new IPAddress(reply.address);
665 IPStatus statusFromCode = GetStatusFromCode((int)reply.status);
666 long rtt;
668 byte[] array;
669 if (statusFromCode == IPStatus.Success)
670 {
671 rtt = reply.roundTripTime;
672 options = new PingOptions(reply.options.ttl, (reply.options.flags & 2) > 0);
673 array = new byte[reply.dataSize];
674 Marshal.Copy(reply.data, array, 0, reply.dataSize);
675 }
676 else
677 {
678 rtt = 0L;
679 options = null;
680 array = Array.Empty<byte>();
681 }
682 return new PingReply(address, options, statusFromCode, rtt, array);
683 }
684
685 private static PingReply CreatePingReplyFromIcmp6EchoReply(global::Interop.IpHlpApi.Icmp6EchoReply reply, IntPtr dataPtr, int sendSize)
686 {
687 IPAddress address = new IPAddress(reply.Address.Address, reply.Address.ScopeID);
688 IPStatus statusFromCode = GetStatusFromCode((int)reply.Status);
689 long rtt;
690 byte[] array;
691 if (statusFromCode == IPStatus.Success)
692 {
693 rtt = reply.RoundTripTime;
694 array = new byte[sendSize];
695 Marshal.Copy(dataPtr + 36, array, 0, sendSize);
696 }
697 else
698 {
699 rtt = 0L;
700 array = Array.Empty<byte>();
701 }
702 return new PingReply(address, null, statusFromCode, rtt, array);
703 }
704}
static Microsoft.Win32.SafeHandles.SafeLocalAllocHandle LocalAlloc(int cb)
static AsyncOperation CreateOperation(object? userSuppliedState)
void PostOperationCompleted(SendOrPostCallback d, object? arg)
static void SuppressFinalize(object obj)
Definition GC.cs:202
Definition GC.cs:8
static Task< IPAddress[]> GetHostAddressesAsync(string hostNameOrAddress)
Definition Dns.cs:205
static IPAddress[] GetHostAddresses(string hostNameOrAddress)
Definition Dns.cs:170
byte[] GetAddressBytes()
Definition IPAddress.cs:377
override bool Equals([NotNullWhen(true)] object? comparand)
Definition IPAddress.cs:468
static bool TryParse([NotNullWhen(true)] string? ipString, [NotNullWhen(true)] out IPAddress? address)
Definition IPAddress.cs:303
static readonly IPAddress Any
Definition IPAddress.cs:19
static readonly IPAddress IPv6Any
Definition IPAddress.cs:27
AddressFamily AddressFamily
Definition IPAddress.cs:88
void SendAsync(string hostNameOrAddress, int timeout, byte[] buffer, object? userToken)
Definition Ping.cs:259
PingReply Send(IPAddress address, int timeout)
Definition Ping.cs:191
PingReply Send(IPAddress address)
Definition Ping.cs:186
SendOrPostCallback _onPingCompletedDelegate
Definition Ping.cs:15
Task< PingReply > DoSendPingCore(IPAddress address, byte[] buffer, int timeout, PingOptions options, bool isAsync)
Definition Ping.cs:457
TaskCompletionSource< PingReply > _taskCompletionSource
Definition Ping.cs:43
PingReply GetAddressAndSend(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions options)
Definition Ping.cs:374
void SendAsync(IPAddress address, int timeout, byte[] buffer, PingOptions? options, object? userToken)
Definition Ping.cs:274
Task< PingReply > SendPingAsync(string hostNameOrAddress)
Definition Ping.cs:298
PingReply Send(IPAddress address, int timeout, byte[] buffer)
Definition Ping.cs:201
Task< PingReply > SendPingAsync(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions? options)
Definition Ping.cs:348
Task< PingReply > SendPingAsyncCore(IPAddress address, byte[] buffer, int timeout, PingOptions options)
Definition Ping.cs:452
void CheckArgs(int timeout, byte[] buffer, PingOptions options)
Definition Ping.cs:71
PingReply SendPingCore(IPAddress address, byte[] buffer, int timeout, PingOptions options)
Definition Ping.cs:447
void CheckArgs(IPAddress address, int timeout, byte[] buffer, PingOptions options)
Definition Ping.cs:88
Task< PingReply > SendPingAsync(IPAddress address, int timeout)
Definition Ping.cs:303
RegisteredWaitHandle _registeredWait
Definition Ping.cs:33
Task< PingReply > SendPingAsync(string hostNameOrAddress, int timeout)
Definition Ping.cs:308
Task< PingReply > SendPingAsync(IPAddress address, int timeout, byte[] buffer, PingOptions? options)
Definition Ping.cs:323
unsafe void SetUnmanagedStructures(byte[] buffer)
Definition Ping.cs:634
void SendAsync(string hostNameOrAddress, int timeout, object? userToken)
Definition Ping.cs:244
SafeWaitHandle GetWaitHandle(bool async)
Definition Ping.cs:532
PingReply Send(string hostNameOrAddress)
Definition Ping.cs:176
async Task< PingReply > SendPingAsyncInternal(IPAddress address, int timeout, byte[] buffer, PingOptions options)
Definition Ping.cs:329
SafeLocalAllocHandle _replyBuffer
Definition Ping.cs:37
PingReply Send(IPAddress address, int timeout, byte[] buffer, PingOptions? options)
Definition Ping.cs:220
void Cleanup(bool isAsync)
Definition Ping.cs:588
int SendEcho(IPAddress address, byte[] buffer, int timeout, PingOptions options, bool isAsync)
Definition Ping.cs:563
async Task< PingReply > GetAddressAndSendAsync(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions options)
Definition Ping.cs:392
static IPAddress GetAddressSnapshot(IPAddress address)
Definition Ping.cs:131
global::Interop.IpHlpApi.SafeCloseIcmpHandle _handlePingV6
Definition Ping.cs:41
Task< PingReply > SendPingAsync(string hostNameOrAddress, int timeout, byte[] buffer)
Definition Ping.cs:318
void TestIsIpSupported(IPAddress ip)
Definition Ping.cs:410
Task< PingReply > SendPingAsync(IPAddress address, int timeout, byte[] buffer)
Definition Ping.cs:313
static PingReply CreatePingReplyFromIcmpEchoReply(global::Interop.IpHlpApi.IcmpEchoReply reply)
Definition Ping.cs:662
void SendAsync(IPAddress address, int timeout, byte[] buffer, object? userToken)
Definition Ping.cs:264
static IPStatus GetStatusFromCode(int statusCode)
Definition Ping.cs:653
static readonly SafeWaitHandle s_nullSafeWaitHandle
Definition Ping.cs:25
PingReply Send(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions? options)
Definition Ping.cs:206
override void Dispose(bool disposing)
Definition Ping.cs:163
SafeLocalAllocHandle _requestBuffer
Definition Ping.cs:35
void SendAsync(string hostNameOrAddress, object? userToken)
Definition Ping.cs:239
void SendAsync(string hostNameOrAddress, int timeout, byte[] buffer, PingOptions? options, object? userToken)
Definition Ping.cs:269
readonly ManualResetEventSlim _lockObject
Definition Ping.cs:13
Task< PingReply > SendPingAsync(IPAddress address)
Definition Ping.cs:293
void OnPingCompleted(PingCompletedEventArgs e)
Definition Ping.cs:171
global::Interop.IpHlpApi.SafeCloseIcmpHandle _handlePingV4
Definition Ping.cs:39
void TranslateTaskToEap(object userToken, Task< PingReply > pingTask)
Definition Ping.cs:279
PingCompletedEventHandler? PingCompleted
Definition Ping.cs:61
void SendAsync(IPAddress address, object? userToken)
Definition Ping.cs:249
PingReply Send(string hostNameOrAddress, int timeout)
Definition Ping.cs:181
PingReply Send(string hostNameOrAddress, int timeout, byte[] buffer)
Definition Ping.cs:196
ManualResetEvent _pingEvent
Definition Ping.cs:31
void SendAsync(IPAddress address, int timeout, object? userToken)
Definition Ping.cs:254
static PingReply CreatePingReplyFromIcmp6EchoReply(global::Interop.IpHlpApi.Icmp6EchoReply reply, IntPtr dataPtr, int sendSize)
Definition Ping.cs:685
static System.Net.Internals.SocketAddress Serialize(EndPoint endpoint)
static void Copy(int[] source, int startIndex, IntPtr destination, int length)
Definition Marshal.cs:800
static ? object PtrToStructure(IntPtr ptr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type structureType)
Definition Marshal.cs:1164
static string net_invalid_ip_addr
Definition SR.cs:16
static string net_ping
Definition SR.cs:20
static string net_inasync
Definition SR.cs:64
static string net_ipv4_not_installed
Definition SR.cs:22
static string net_ipv6_not_installed
Definition SR.cs:24
static string net_invalidPingBufferSize
Definition SR.cs:16
Definition SR.cs:7
Task ContinueWith(Action< Task< TResult > > continuationAction)
Definition Task.cs:263
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
Definition Task.cs:226
AggregateException? Exception
Definition Task.cs:1014
static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce, bool flowExecutionContext)
virtual void Dispose(bool explicitDisposing)
delegate void PingCompletedEventHandler(object sender, PingCompletedEventArgs e)
static readonly IntPtr Zero
Definition IntPtr.cs:18