Struct SteamNetworkingIPAddr
An IP address and port. The address is always stored as IPv6, with IPv4 as an IPv4-mapped address (RFC 4291 §2.5.5.2: aa.bb.cc.dd is ::ffff:aabb:ccdd). Packed to 1 like the C++ struct, so it is exactly 18 bytes: 16 address bytes, then the port. Methods call the SDK's flat accessors, so they behave exactly like the C++ ones.
Implements
Inherited Members
Namespace: Unity.Steamworks.Interop
Assembly: Unity.Steamworks.Interop.dll
Syntax
[Serializable]
public struct SteamNetworkingIPAddr : IEquatable<SteamNetworkingIPAddr>
Fields
k_cchMaxString
Buffer size, including the terminator, that fits any ToString(bool) output. The longest is [0123:4567:89ab:cdef:0123:4567:89ab:cdef]:12345.
Declaration
public const int k_cchMaxString = 48
Field Value
| Type | Description |
|---|---|
| int |
m_ipv6
The 16 address bytes, in network byte order as in in6_addr.
Declaration
public byte[] m_ipv6
Field Value
| Type | Description |
|---|---|
| byte[] |
m_port
The port, in host byte order.
Declaration
public ushort m_port
Field Value
| Type | Description |
|---|---|
| ushort |
Methods
Clear()
Sets the address and port to zero ([::]:0).
Declaration
public void Clear()
Equals(object)
Compares this address with another object.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with. |
Returns
| Type | Description |
|---|---|
| bool | true when |
Overrides
Equals(SteamNetworkingIPAddr)
Compares this address with another.
Declaration
public bool Equals(SteamNetworkingIPAddr other)
Parameters
| Type | Name | Description |
|---|---|---|
| SteamNetworkingIPAddr | other | The address to compare with. |
Returns
| Type | Description |
|---|---|
| bool | true when both the IP and the port match. |
GetFakeIPType()
Classifies the address as FakeIP; never returns k_ESteamNetworkingFakeIPType_Invalid.
Declaration
public ESteamNetworkingFakeIPType GetFakeIPType()
Returns
| Type | Description |
|---|---|
| ESteamNetworkingFakeIPType | The |
GetHashCode()
Hashes the IP and port, consistently with Equals(SteamNetworkingIPAddr).
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | The hash code. |
Overrides
GetIPv4()
Gets the IPv4 address in host byte order.
Declaration
public uint GetIPv4()
Returns
| Type | Description |
|---|---|
| uint | The address, aa.bb.cc.dd as 0xaabbccdd, or 0 when it is not IPv4-mapped. |
IsFakeIP()
Checks whether the address is a FakeIP.
Declaration
public bool IsFakeIP()
Returns
| Type | Description |
|---|---|
| bool | true when GetFakeIPType() reports a FakeIP type. |
IsIPv4()
Checks whether the address is IPv4.
Declaration
public bool IsIPv4()
Returns
| Type | Description |
|---|---|
| bool | true for an IPv4-mapped address, false for any other IPv6 address. |
IsIPv6AllZeros()
Checks whether the IP is :: (all zeros), ignoring the port.
Declaration
public bool IsIPv6AllZeros()
Returns
| Type | Description |
|---|---|
| bool | true when all 16 address bytes are zero. |
IsLocalHost()
Checks whether the address is localhost.
Declaration
public bool IsLocalHost()
Returns
| Type | Description |
|---|---|
| bool | true for ::1 or 127.0.0.1. |
ParseString(string)
Parses an IP address and optional port into this value. A missing port is read as 0, so it is indistinguishable from an explicit :0.
Declaration
public bool ParseString(string pszStr)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pszStr | The text to parse, e.g. 12.34.56.78:80 or [::1]:80. |
Returns
| Type | Description |
|---|---|
| bool | true when the string was a valid address. |
SetIPv4(uint, ushort)
Sets an IPv4 address, stored IPv4-mapped, and the port.
Declaration
public void SetIPv4(uint nIP, ushort nPort)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | nIP | The address in host byte order: aa.bb.cc.dd as 0xaabbccdd. |
| ushort | nPort | The port, in host byte order. |
SetIPv6(byte[], ushort)
Sets the address from raw IPv6 bytes, which may be an IPv4-mapped address, and the port.
Declaration
public void SetIPv6(byte[] ipv6, ushort nPort)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | ipv6 | The 16 address bytes, copied as-is (network byte order). |
| ushort | nPort | The port, in host byte order. |
SetIPv6LocalHost(ushort)
Sets the IPv6 localhost address ::1 with the given port.
Declaration
public void SetIPv6LocalHost(ushort nPort = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| ushort | nPort | The port, in host byte order. |
ToString()
Formats the address with its port; see ToString(bool).
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The formatted address and port. |
Overrides
ToString(bool)
Formats the address: IPv4 as dotted decimal (12.34.56.78), IPv6 in RFC 5952 canonical form, bracketed when the port is included (e.g. [::1:2]:80).
Declaration
public string ToString(bool bWithPort)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | bWithPort | true to append the port. |
Returns
| Type | Description |
|---|---|
| string | The formatted address. |