Unified · Split
| @@ -131,7 +131,7 @@ namespace GSF.Communication · 130 unmodified lines | ||
| 131 | 131 | #if !MONO |
| 132 | 132 | if (stack == IPStack.IPv4 && !Socket.OSSupportsIPv4) |
| 133 | 133 | throw new NotSupportedException($"IPv4 stack is not available for socket creation on {hostNameOrAddress.ToNonNullNorWhiteSpace("localhost")}:{port}"); |
| 134 | −#endif | |
| 134 | + #endif | |
| 135 | 135 | |
| 136 | 136 | // No host name or IP address was specified, use local IPs |
| 137 | 137 | if (string.IsNullOrWhiteSpace(hostNameOrAddress)) |
| @@ -325,7 +325,28 @@ namespace GSF.Communication · 324 unmodified lines | ||
| 325 | 325 | /// Gets the server URI of the <see cref="UdpClient"/>. |
| 326 | 326 | /// </summary> |
| 327 | 327 | [Browsable(false)] |
| 328 | − public override string ServerUri => $"{TransportProtocol}://{m_connectData["server"]}".ToLower(); | |
| 328 | + public override string ServerUri | |
| 329 | + { | |
| 330 | + get | |
| 331 | + { | |
| 332 | + if (m_connectData is null) | |
| 333 | + return $"{TransportProtocol}://0.0.0.0:0"; | |
| 334 | + | |
| 335 | + if (m_connectData.ContainsKey("server")) | |
| 336 | + return $"{TransportProtocol}://{m_connectData["server"]}".ToLower(); | |
| 337 | + | |
| 338 | + if (!m_connectData.TryGetValue("interface", out string targetInterface) || string.IsNullOrWhiteSpace(targetInterface)) | |
| 339 | + { | |
| 340 | + IPStack ipStack = m_ipStack == IPStack.Default ? Transport.GetDefaultIPStack() : m_ipStack; | |
| 341 | + targetInterface = ipStack == IPStack.IPv6 ? "[::0]" : "0.0.0.0"; | |
| 342 | + } | |
| 343 | + | |
| 344 | + if (!m_connectData.TryGetValue("port", out string targetPort) || !ushort.TryParse(targetPort, out ushort port)) | |
| 345 | + port = 0; | |
| 346 | + | |
| 347 | + return $"{TransportProtocol}://{targetInterface}:{port}".ToLower(); | |
| 348 | + } | |
| 349 | + } | |
| 329 | 350 | |
| 330 | 351 | /// <summary> |
| 331 | 352 | /// Gets or sets the size of the buffer used by the client for receiving data from the server. |