docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct NetworkEndPoint

    Describes a raw network endpoint (typically IP and port number).

    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    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
    NetworkEndPoint

    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
    NetworkEndPoint

    Family

    Gets or sets NetworkFamily of the endpoint.

    Declaration
    public NetworkFamily Family { get; set; }
    Property Value
    Type Description
    NetworkFamily

    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
    NetworkEndPoint

    LoopbackIpv6

    Gets an IPv6 loopback endpoint ([::1]:0).

    Declaration
    public static NetworkEndPoint LoopbackIpv6 { get; }
    Property Value
    Type Description
    NetworkEndPoint

    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
    ValueType.Equals(object)

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()

    GetRawAddressBytes()

    Gets the raw bytes for the endpoint.

    Declaration
    public NativeArray<byte> GetRawAddressBytes()
    Returns
    Type Description
    NativeArray<byte>

    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.

    NetworkFamily family

    Address family of 'address'.

    Returns
    Type Description
    NetworkEndPoint

    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
    NativeArray<byte> bytes

    Raw bytes to use for the endpoint.

    NetworkFamily family

    Endpoint's address family.

    Exceptions
    Type Condition
    InvalidOperationException

    Length of bytes doesn't match family.

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    ValueType.ToString()

    TryParse(string, ushort, out NetworkEndPoint, NetworkFamily)

    Try to parse the given address and port into a new NetworkEndPoint.

    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.

    NetworkEndPoint endpoint

    Return value for the parsed endpoint.

    NetworkFamily 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
    NetworkEndPoint

    The endpoint (this).

    Operators

    operator ==(NetworkEndPoint, NetworkEndPoint)

    Declaration
    public static bool operator ==(NetworkEndPoint lhs, NetworkEndPoint rhs)
    Parameters
    Type Name Description
    NetworkEndPoint lhs
    NetworkEndPoint rhs
    Returns
    Type Description
    bool

    operator !=(NetworkEndPoint, NetworkEndPoint)

    Declaration
    public static bool operator !=(NetworkEndPoint lhs, NetworkEndPoint rhs)
    Parameters
    Type Name Description
    NetworkEndPoint lhs
    NetworkEndPoint rhs
    Returns
    Type Description
    bool
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)