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

host string
port ushort

Properties

Host

The host name or IP, without brackets.

public string Host { get; }

Property Value

string

Port

The port.

public ushort Port { get; }

Property Value

ushort

Methods

ToString()

host:port, with an IPv6 host in brackets.

public override string ToString()

Returns

string

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

text string

What the player typed.

defaultPort ushort

The port to use when none is typed.

address HostAddress

The address read, when the result is true.

error string

A sentence to show the player, when the result is false.

Returns

bool