From 45fad4c1b29005f4a8e64ef52dc699c20eb56474 Mon Sep 17 00:00:00 2001 From: Alecio Furanze Date: Sat, 16 Dec 2023 13:19:18 +0200 Subject: [PATCH] set the default value on the ``host`` instance in the tcp and udp properties, this avoids null references. the default value is ``0.0.0.0:0`` --- src/Abstract/Client.cs | 2 +- src/Abstract/Server.cs | 2 +- src/Udp/UdpClient.cs | 3 +-- src/Udp/UdpServer.cs | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Abstract/Client.cs b/src/Abstract/Client.cs index 5755f380..f7d8013e 100644 --- a/src/Abstract/Client.cs +++ b/src/Abstract/Client.cs @@ -14,7 +14,7 @@ public abstract class Client : IClient public bool Framing { get; protected set; } public string UUID { get; protected set; } - public Host Host { get; protected set; } + public Host Host { get; protected set; } = Host.Default; public bool IsOpened => IsConnected(); diff --git a/src/Abstract/Server.cs b/src/Abstract/Server.cs index 268abc51..a7f0a400 100644 --- a/src/Abstract/Server.cs +++ b/src/Abstract/Server.cs @@ -10,7 +10,7 @@ public abstract class Server { #region Props public bool Framing { get; protected set; } - public Host Host { get; protected set; } + public Host Host { get; protected set; } = Host.Default; public List Clients { get; protected set; } = new List(); public bool IsOpened => IsConnected(); diff --git a/src/Udp/UdpClient.cs b/src/Udp/UdpClient.cs index 9549e1af..a044883e 100644 --- a/src/Udp/UdpClient.cs +++ b/src/Udp/UdpClient.cs @@ -25,7 +25,7 @@ public class UdpClient : IUdpClient /// /// Host container /// - public Host Host { get; private set; } + public Host Host { get; private set; } = Host.Default; /// /// Return true when connection is enabled (using ping) @@ -69,7 +69,6 @@ public UdpClient(bool useConnection, int timeout = _DEFAULT_TIMEOUT_VALUE) _opened = false; _serverside = false; _socket = null; - Host = new Host(IPAddress.Loopback, 0); Init(); } diff --git a/src/Udp/UdpServer.cs b/src/Udp/UdpServer.cs index 0a3eef36..51cbfa66 100644 --- a/src/Udp/UdpServer.cs +++ b/src/Udp/UdpServer.cs @@ -16,7 +16,7 @@ public class UdpServer : IUdpServer /// /// Host container /// - public Host Host { get; private set; } + public Host Host { get; private set; } = Host.Default; /// /// Connection timeout