Struct NetworkEndPoint
Describes a raw network endpoint (typically IP and port number).
Inherited Members
Namespace: Unity.Networking.Transport
Assembly: Unity.Networking.Transport.dll
Syntax
public struct NetworkEndPoint
Properties
Address
Gets the endpoint's representation as a string.
Declaration
public string Address { get; }
Property Value
Type | Description |
---|---|
string |
AnyIpv4
Gets an IPv4 endpoint that can be used to bind to any address available (0.0.0.0:0).
Declaration
public static NetworkEndPoint AnyIpv4 { get; }
Property Value
Type | Description |
---|---|
Network |
AnyIpv6
Gets an IPv6 endpoint that can be used to bind to any address available ([::0]:0).
Declaration
public static NetworkEndPoint AnyIpv6 { get; }
Property Value
Type | Description |
---|---|
Network |
Family
Gets or sets Network
Declaration
public NetworkFamily Family { get; set; }
Property Value
Type | Description |
---|---|
Network |
IsAny
Whether the endpoint is using an "any" address.
Declaration
public bool IsAny { get; }
Property Value
Type | Description |
---|---|
bool |
IsLoopback
Whether the endpoint is using a loopback address.
Declaration
public bool IsLoopback { get; }
Property Value
Type | Description |
---|---|
bool |
IsValid
Whether the endpoint is valid or not.
Declaration
public bool IsValid { get; }
Property Value
Type | Description |
---|---|
bool |
Length
Returns the length of the raw network endpoint in bytes.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
int |
LoopbackIpv4
Gets an IPv4 loopback endpoint (127.0.0.1:0).
Declaration
public static NetworkEndPoint LoopbackIpv4 { get; }
Property Value
Type | Description |
---|---|
Network |
LoopbackIpv6
Gets an IPv6 loopback endpoint ([::1]:0).
Declaration
public static NetworkEndPoint LoopbackIpv6 { get; }
Property Value
Type | Description |
---|---|
Network |
Port
Gets or sets port number of the endpoint.
Declaration
public ushort Port { get; set; }
Property Value
Type | Description |
---|---|
ushort |
RawPort
Gets or sets the value of the raw port number.
Declaration
public ushort RawPort { get; set; }
Property Value
Type | Description |
---|---|
ushort |
Methods
Equals(object)
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
object | other |
Returns
Type | Description |
---|---|
bool |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
GetRawAddressBytes()
Gets the raw bytes for the endpoint.
Declaration
public NativeArray<byte> GetRawAddressBytes()
Returns
Type | Description |
---|---|
Native |
Native array containing the raw bytes (uses temporary allocation). |
Parse(string, ushort, NetworkFamily)
Same as TryParse<T>, except an endpoint is always returned. If the given address, port, and family don't represent a valid endpoint, the default one is returned.
Declaration
public static NetworkEndPoint Parse(string address, ushort port, NetworkFamily family = NetworkFamily.Ipv4)
Parameters
Type | Name | Description |
---|---|---|
string | address | String representation of the address. |
ushort | port | Return value for the parsed endpoint. |
Network |
family | Address family of 'address'. |
Returns
Type | Description |
---|---|
Network |
Parsed network endpoint (default if parsing failed). |
SetRawAddressBytes(NativeArray<byte>, NetworkFamily)
Directly sets the raw bytes of the endpoint using the specified bytes and family.
Declaration
public void SetRawAddressBytes(NativeArray<byte> bytes, NetworkFamily family = NetworkFamily.Ipv4)
Parameters
Type | Name | Description |
---|---|---|
Native |
bytes | Raw bytes to use for the endpoint. |
Network |
family | Endpoint's address family. |
Exceptions
Type | Condition |
---|---|
Invalid |
Length of bytes doesn't match family. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |
Overrides
TryParse(string, ushort, out NetworkEndPoint, NetworkFamily)
Try to parse the given address and port into a new Network
Declaration
public static bool TryParse(string address, ushort port, out NetworkEndPoint endpoint, NetworkFamily family = NetworkFamily.Ipv4)
Parameters
Type | Name | Description |
---|---|---|
string | address | String representation of the address. |
ushort | port | Port number. |
Network |
endpoint | Return value for the parsed endpoint. |
Network |
family | Address family of 'address'. |
Returns
Type | Description |
---|---|
bool | Whether the endpoint was successfully parsed or not. |
WithPort(ushort)
Use the given port number for this endpoint.
Declaration
public NetworkEndPoint WithPort(ushort port)
Parameters
Type | Name | Description |
---|---|---|
ushort | port | The port number. |
Returns
Type | Description |
---|---|
Network |
The endpoint (this). |
Operators
operator ==(NetworkEndPoint, NetworkEndPoint)
Declaration
public static bool operator ==(NetworkEndPoint lhs, NetworkEndPoint rhs)
Parameters
Type | Name | Description |
---|---|---|
Network |
lhs | |
Network |
rhs |
Returns
Type | Description |
---|---|
bool |
operator !=(NetworkEndPoint, NetworkEndPoint)
Declaration
public static bool operator !=(NetworkEndPoint lhs, NetworkEndPoint rhs)
Parameters
Type | Name | Description |
---|---|---|
Network |
lhs | |
Network |
rhs |
Returns
Type | Description |
---|---|
bool |