Interface INatDiscoverer
Discovers NAT device;
Inherited Members
Namespace: SharpOpenNat
Assembly: SharpOpenNat.dll
Syntax
public interface INatDiscoverer : IDisposable
Methods
| Edit this page View SourceDiscoverDeviceAsync(PortMapper, CancellationToken)
Discovers and returns a NAT device for the specified type; otherwise a NatDeviceNotFoundException exception is thrown when it is cancelled.
Declaration
Task<INatDevice> DiscoverDeviceAsync(PortMapper portMapper, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| PortMapper | portMapper | Port mapper protocol; Upnp, Pmp or both |
| CancellationToken | cancellationToken | Cancellation token for cancelling the discovery process |
Returns
| Type | Description |
|---|---|
| Task<INatDevice> | A NAT device |
Remarks
It allows to specify the NAT type to discover as well as the cancellation token in order.
Exceptions
| Type | Condition |
|---|---|
| NatDeviceNotFoundException | when no NAT found before cancellation |
DiscoverDeviceAsync(CancellationToken)
Discovers and returns an UPnp or Pmp NAT device; otherwise a NatDeviceNotFoundException exception is thrown after 3 seconds.
Declaration
Task<INatDevice> DiscoverDeviceAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<INatDevice> | A NAT device |
Exceptions
| Type | Condition |
|---|---|
| NatDeviceNotFoundException | when no NAT found before 3 seconds. |
DiscoverDevicesAsync(PortMapper, CancellationToken)
Discovers and returns all NAT devices for the specified type. If no NAT device is found it returns an empty enumerable
Declaration
Task<IEnumerable<INatDevice>> DiscoverDevicesAsync(PortMapper portMapper, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| PortMapper | portMapper | Port mapper protocol; Upnp, Pmp or both |
| CancellationToken | cancellationToken | Cancellation token for cancelling the discovery process |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<INatDevice>> | All found NAT devices |