Struct NetworkEndpointAddress
Represents a network endpoint, wrapping a Unity.Networking.Transport.NetworkEndpoint. Provides utility properties and constructors for working with IP addresses and ports in Unity Multiplayer.
Inherited Members
Namespace: Unity.Services.Multiplayer
Assembly: Unity.Services.Multiplayer.dll
Syntax
public struct NetworkEndpointAddress
Constructors
NetworkEndpointAddress(string, ushort)
Initializes a new instance of the NetworkEndpointAddress struct from an IP address and port.
Declaration
public NetworkEndpointAddress(string ip, ushort port)
Parameters
Type | Name | Description |
---|---|---|
string | ip | The IPv4 or IPv6 address as a string. |
ushort | port | The port number. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the IP address is not valid. |
NetworkEndpointAddress(NetworkEndpoint)
Initializes a new instance of the NetworkEndpointAddress struct from an existing Unity Transport endpoint.
Declaration
public NetworkEndpointAddress(NetworkEndpoint utpEndpoint)
Parameters
Type | Name | Description |
---|---|---|
NetworkEndpoint | utpEndpoint | The Unity Transport network endpoint. |
Fields
AnyIpv4
Gets an IPv4 ListenIPAddress representing any address.
Declaration
public static readonly NetworkEndpointAddress AnyIpv4
Field Value
Type | Description |
---|---|
NetworkEndpointAddress |
AnyIpv6
Gets an IPv6 ListenIPAddress representing any address.
Declaration
public static readonly NetworkEndpointAddress AnyIpv6
Field Value
Type | Description |
---|---|
NetworkEndpointAddress |
LoopbackIpv4
Gets an IPv4 PublishIPAddress representing the loopback address.
Declaration
public static readonly NetworkEndpointAddress LoopbackIpv4
Field Value
Type | Description |
---|---|
NetworkEndpointAddress |
LoopbackIpv6
Gets an IPv6 PublishIPAddress representing the loopback address.
Declaration
public static readonly NetworkEndpointAddress LoopbackIpv6
Field Value
Type | Description |
---|---|
NetworkEndpointAddress |
Properties
Address
Gets the address (IP and port) as a string.
Declaration
public string Address { get; }
Property Value
Type | Description |
---|---|
string |
Remarks
For an IPv4 address the format is as follows.
ip_address:port
, e.g. 127.0.0.1:567
.
For an IPv6 address the format is as follows.
[ip_address]:port
, e.g.
,[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:567
.
AddressNoPort
Gets the address (IP only, no port) as a string.
Declaration
public string AddressNoPort { get; }
Property Value
Type | Description |
---|---|
string |
Port
Gets the port of the endpoint.
Declaration
public ushort Port { get; }
Property Value
Type | Description |
---|---|
ushort |
UtpEndpoint
Gets the underlying Unity Transport network endpoint.
Declaration
public NetworkEndpoint UtpEndpoint { get; }
Property Value
Type | Description |
---|---|
NetworkEndpoint |
Methods
WithPort(ushort)
Returns a copy of this NetworkEndpointAddress with the specified port.
Declaration
public readonly NetworkEndpointAddress WithPort(ushort port)
Parameters
Type | Name | Description |
---|---|---|
ushort | port | The port to set. |
Returns
Type | Description |
---|---|
NetworkEndpointAddress | A new NetworkEndpointAddress with the updated port. |