Skip to content

Commit

Permalink
Add all standard UdpClient properties to UdpClientRx
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPulman committed Jul 22, 2022
1 parent e3690ab commit 88bd66e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Version>2.2.5</Version>
<Version>2.2.6</Version>
<Authors>Chris Pulman</Authors>
<TargetFrameworks>net461;netstandard2.0;net6.0;</TargetFrameworks>
<Description>An Observable Com port extension of System.IO.Ports.SerialPort</Description>
Expand Down
75 changes: 68 additions & 7 deletions SerialPortRx/UdpClientRx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ public class UdpClientRx : IPortRx
private bool _disposedValue;
private int _bufferOffset;

/// <summary>
/// Initializes a new instance of the <see cref="UdpClientRx"/> class.
/// </summary>
public UdpClientRx()
: this(AddressFamily.InterNetwork)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="UdpClientRx"/> class.
/// </summary>
Expand All @@ -52,16 +60,15 @@ public class UdpClientRx : IPortRx
/// <summary>
/// Initializes a new instance of the <see cref="UdpClientRx"/> class.
/// </summary>
public UdpClientRx()
: this(AddressFamily.InterNetwork)
{
}
/// <param name="family">The family.</param>
public UdpClientRx(AddressFamily family) => _udpClient = new(family);

/// <summary>
/// Initializes a new instance of the <see cref="UdpClientRx"/> class.
/// </summary>
/// <param name="port">The port.</param>
/// <param name="family">The family.</param>
public UdpClientRx(AddressFamily family) => _udpClient = new(family);
public UdpClientRx(int port, AddressFamily family) => _udpClient = new(port, family);

/// <summary>
/// Initializes a new instance of the <see cref="UdpClientRx"/> class.
Expand All @@ -70,6 +77,54 @@ public UdpClientRx()
/// <param name="port">The port.</param>
public UdpClientRx(string hostname, int port) => _udpClient = new(hostname, port);

/// <summary>
/// Gets the available.
/// </summary>
/// <value>
/// The available.
/// </value>
public int Available => _udpClient!.Available;

/// <summary>
/// Gets or sets the TTL.
/// </summary>
/// <value>
/// The TTL.
/// </value>
public short Ttl { get => _udpClient!.Ttl; set => _udpClient!.Ttl = value; }

/// <summary>
/// Gets or sets a value indicating whether [dont fragment].
/// </summary>
/// <value>
/// <c>true</c> if [dont fragment]; otherwise, <c>false</c>.
/// </value>
public bool DontFragment { get => _udpClient!.DontFragment; set => _udpClient!.DontFragment = value; }

/// <summary>
/// Gets or sets a value indicating whether [multicast loopback].
/// </summary>
/// <value>
/// <c>true</c> if [multicast loopback]; otherwise, <c>false</c>.
/// </value>
public bool MulticastLoopback { get => _udpClient!.MulticastLoopback; set => _udpClient!.MulticastLoopback = value; }

/// <summary>
/// Gets or sets a value indicating whether [enable broadcast].
/// </summary>
/// <value>
/// <c>true</c> if [enable broadcast]; otherwise, <c>false</c>.
/// </value>
public bool EnableBroadcast { get => _udpClient!.EnableBroadcast; set => _udpClient!.EnableBroadcast = value; }

/// <summary>
/// Gets or sets a value indicating whether [exclusive address use].
/// </summary>
/// <value>
/// <c>true</c> if [exclusive address use]; otherwise, <c>false</c>.
/// </value>
public bool ExclusiveAddressUse { get => _udpClient!.ExclusiveAddressUse; set => _udpClient!.ExclusiveAddressUse = value; }

/// <summary>
/// Gets the infinite timeout.
/// </summary>
Expand All @@ -79,12 +134,12 @@ public UdpClientRx()
public int InfiniteTimeout => Timeout.Infinite;

/// <summary>
/// Gets the underlying System.Net.Sockets.Socket.
/// Gets or sets the underlying System.Net.Sockets.Socket.
/// </summary>
/// <value>
/// The underlying network System.Net.Sockets.Socket.
/// </value>
public Socket Client => _udpClient!.Client;
public Socket Client { get => _udpClient!.Client; set => _udpClient!.Client = value; }

/// <summary>
/// Gets or sets the read timeout.
Expand Down Expand Up @@ -122,6 +177,12 @@ public int WriteTimeout
/// <value>The data received.</value>
public IObservable<int> BytesReceived => _bytesReceived.Retry().Publish().RefCount();

/// <summary>
/// Allows the nat traversal.
/// </summary>
/// <param name="allowed">if set to <c>true</c> [allowed].</param>
public void AllowNatTraversal(bool allowed) => _udpClient!.AllowNatTraversal(allowed);

/// <summary>
/// Connects the specified hostname.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "2.2.5",
"version": "2.2.6",
"nuGetPackageVersion": {
"semVer": 2.0
},
Expand Down

0 comments on commit 88bd66e

Please sign in to comment.