Struct HostAddress
- Namespace
- Unity.Multiplayer.Core
A server address as a player types it into a "Join by IP" box: 192.168.1.20, 192.168.1.20:7777,
game.example.com:7777, ::1 or [::1]:7777. The port is optional and defaults to the game's.
public readonly struct HostAddress
- Inherited Members
Constructors
HostAddress(string, ushort)
Creates an address.
public HostAddress(string host, ushort port)
Parameters
Properties
Host
The host name or IP, without brackets.
public string Host { get; }
Property Value
Port
The port.
public ushort Port { get; }
Property Value
Methods
ToString()
host:port, with an IPv6 host in brackets.
public override string ToString()
Returns
TryParse(string, ushort, out HostAddress, out string)
Reads text. Whitespace around it is ignored; a missing port is defaultPort.
An IPv6 address takes a port only in brackets ([::1]:7777), since its colons are ambiguous otherwise.
public static bool TryParse(string text, ushort defaultPort, out HostAddress address, out string error)
Parameters
textstringWhat the player typed.
defaultPortushortThe port to use when none is typed.
addressHostAddressThe address read, when the result is true.
errorstringA sentence to show the player, when the result is false.