Loading...
Searching...
No Matches
juce::IPAddress Class Referencefinal

## Detailed Description

Represents an IP address.

The documentation for this class was generated from the following file:

- juce_core/network/juce_IPAddress.h

## Public Member Functions

| IPAddress () noexcept
| Creates a null address - 0.0.0.0 (IPv4) or ::, (IPv6).
| IPAddress (const uint8 *bytes, bool IPv6=false) noexcept
| Creates an IPv4 or IPv6 address by reading 4 or 16 bytes from an array.
| IPAddress (const uint16 *bytes) noexcept
| Creates an IPv6 address from an array of 8 16-bit integers.
| IPAddress (uint8 address1, uint8 address2, uint8 address3, uint8 address4) noexcept
| Creates an IPv4 address from 4 bytes.
| IPAddress (uint16 address1, uint16 address2, uint16 address3, uint16 address4, uint16 address5, uint16 address6, uint16 address7, uint16 address8) noexcept
| Creates an IPv6 address from 8 16-bit integers.
| IPAddress (uint32 asNativeEndian32Bit) noexcept
| Creates an IPv4 address from a packed 32-bit integer, where the MSB is the first number in the address, and the LSB is the last.
| IPAddress (const String &address)
| Parses a string IP address of the form "1.2.3.4" (IPv4) or "1:2:3:4:5:6:7:8" (IPv6).
bool | isNull () const
| Returns whether the address contains the null address (e.g.
String | toString () const
| Returns a dot- or colon-separated string in the form "1.2.3.4" (IPv4) or "1:2:3:4:5:6:7:8" (IPv6).
int | compare (const IPAddress &) const noexcept
| Compares this IPAddress with another.
bool | operator== (const IPAddress &) const noexcept
bool | operator!= (const IPAddress &) const noexcept
bool | operator< (const IPAddress &) const noexcept
bool | operator> (const IPAddress &) const noexcept
bool | operator<= (const IPAddress &) const noexcept
bool | operator>= (const IPAddress &) const noexcept

## Static Public Member Functions

static IPAddress | any () noexcept
| Returns an IP address meaning "any", equivalent to 0.0.0.0 (IPv4) or ::, (IPv6).
static IPAddress | broadcast () noexcept
| Returns an IPv4 address meaning "broadcast" (255.255.255.255).
static IPAddress | local (bool IPv6=false) noexcept
| Returns an IPv4 or IPv6 address meaning "localhost", equivalent to 127.0.0.1 (IPv4) or ::1 (IPv6).
static void | findAllAddresses (Array< IPAddress > &results, bool includeIPv6=false)
| Populates a list of all the IP addresses that this machine is using.
static Array< IPAddress > | getAllAddresses (bool includeIPv6=false)
| Populates a list of all the IP addresses that this machine is using.
static IPAddress | getLocalAddress (bool includeIPv6=false)
| Returns the first 'real' address for the local machine.
static String | getFormattedAddress (const String &unformattedAddress)
| Returns a formatted version of the provided IPv6 address conforming to RFC 5952 with leading zeros suppressed, lower case characters, and double-colon notation used to represent contiguous 16-bit fields of zeros.
static bool | isIPv4MappedAddress (const IPAddress &mappedAddress)
| Returns true if the given IP address is an IPv4-mapped IPv6 address.
static IPAddress | convertIPv4MappedAddressToIPv4 (const IPAddress &mappedAddress)
| Converts an IPv4-mapped IPv6 address to an IPv4 address.
static IPAddress | convertIPv4AddressToIPv4Mapped (const IPAddress &addressToMap)
| Converts an IPv4 address to an IPv4-mapped IPv6 address.
static IPAddress | getInterfaceBroadcastAddress (const IPAddress &interfaceAddress)
| If the IPAdress is the address of an interface on the machine, returns the associated broadcast address.

## Public Attributes

uint8 | address [16]
| The elements of the IP address.
bool | isIPv6 = false

## Constructors and Destructors

## IPAddress() [1/7]

juce::IPAddress::IPAddress | ( |  | ) |

noexcept

Creates a null address - 0.0.0.0 (IPv4) or ::, (IPv6).

References IPAddress().

Referenced by any(), broadcast(), compare(), convertIPv4AddressToIPv4Mapped(), convertIPv4MappedAddressToIPv4(), findAllAddresses(), getAllAddresses(), getInterfaceBroadcastAddress(), getLocalAddress(), IPAddress(), IPAddress(), IPAddress(), IPAddress(), IPAddress(), IPAddress(), IPAddress(), isIPv4MappedAddress(), local(), operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

## IPAddress() [2/7]

juce::IPAddress::IPAddress | ( | const uint8 * | bytes,
|  | bool | IPv6 = false )

explicit noexcept

Creates an IPv4 or IPv6 address by reading 4 or 16 bytes from an array.

Parameters

  bytes | The array containing the bytes to read.
  IPv6 | if true indicates that 16 bytes should be read instead of 4.

References IPAddress().

## IPAddress() [3/7]

juce::IPAddress::IPAddress | ( | const uint16 * | bytes | ) |

explicit noexcept

Creates an IPv6 address from an array of 8 16-bit integers.

Parameters

  bytes | The array containing the bytes to read.

References IPAddress().

## IPAddress() [4/7]

juce::IPAddress::IPAddress | ( | uint8 | address1,
|  | uint8 | address2,
|  | uint8 | address3,
|  | uint8 | address4 )

noexcept

Creates an IPv4 address from 4 bytes.

References IPAddress().

## IPAddress() [5/7]

juce::IPAddress::IPAddress | ( | uint16 | address1,
|  | uint16 | address2,
|  | uint16 | address3,
|  | uint16 | address4,
|  | uint16 | address5,
|  | uint16 | address6,
|  | uint16 | address7,
|  | uint16 | address8 )

noexcept

Creates an IPv6 address from 8 16-bit integers.

References IPAddress().

## IPAddress() [6/7]

juce::IPAddress::IPAddress | ( | uint32 | asNativeEndian32Bit | ) |

explicit noexcept

Creates an IPv4 address from a packed 32-bit integer, where the MSB is the first number in the address, and the LSB is the last.

References IPAddress().

## IPAddress() [7/7]

juce::IPAddress::IPAddress | ( | const String & | address | ) |

explicit

Parses a string IP address of the form "1.2.3.4" (IPv4) or "1:2:3:4:5:6:7:8" (IPv6).

References address, and IPAddress().

## Member Functions

## any()

IPAddress juce::IPAddress::any | ( |  | ) |

static noexcept

Returns an IP address meaning "any", equivalent to 0.0.0.0 (IPv4) or ::, (IPv6).

References IPAddress().

## broadcast()

IPAddress juce::IPAddress::broadcast | ( |  | ) |

static noexcept

Returns an IPv4 address meaning "broadcast" (255.255.255.255).

References broadcast(), and IPAddress().

Referenced by broadcast().

## local()

IPAddress juce::IPAddress::local | ( | bool | IPv6 = false | ) |

static noexcept

Returns an IPv4 or IPv6 address meaning "localhost", equivalent to 127.0.0.1 (IPv4) or ::1 (IPv6).

References IPAddress(), and local().

Referenced by local().

## findAllAddresses()

void juce::IPAddress::findAllAddresses | ( | Array< IPAddress > & | results,
|  | bool | includeIPv6 = false )

static

Populates a list of all the IP addresses that this machine is using.

References findAllAddresses(), and IPAddress().

Referenced by findAllAddresses().

## getAllAddresses()

Array< IPAddress > juce::IPAddress::getAllAddresses | ( | bool | includeIPv6 = false | ) |

static

Populates a list of all the IP addresses that this machine is using.

References getAllAddresses(), and IPAddress().

Referenced by getAllAddresses().

## getLocalAddress()

IPAddress juce::IPAddress::getLocalAddress | ( | bool | includeIPv6 = false | ) |

static

Returns the first 'real' address for the local machine.

Unlike local(), this will attempt to find the machine's actual assigned address rather than "127.0.0.1". If there are multiple network cards, this may return any of their addresses. If it doesn't find any, then it'll return local() as a fallback.

References getLocalAddress(), and IPAddress().

Referenced by getLocalAddress().

## isNull()

bool juce::IPAddress::isNull | ( |  | ) | const

Returns whether the address contains the null address (e.g.

0.0.0.0).

References isNull().

Referenced by isNull().

## toString()

String juce::IPAddress::toString | ( |  | ) | const

Returns a dot- or colon-separated string in the form "1.2.3.4" (IPv4) or "1:2:3:4:5:6:7:8" (IPv6).

References toString().

Referenced by toString().

## compare()

int juce::IPAddress::compare | ( | const IPAddress & |  | ) | const

noexcept

Compares this IPAddress with another.

Returns
  0 if the two addresses are identical, negative if this address is smaller than the other one, or positive if is greater.

References compare(), and IPAddress().

Referenced by compare().

## operator==()

bool juce::IPAddress::operator== | ( | const IPAddress & |  | ) | const

noexcept

References IPAddress().

## operator!=()

bool juce::IPAddress::operator!= | ( | const IPAddress & |  | ) | const

noexcept

References IPAddress().

## operator<()

bool juce::IPAddress::operator< | ( | const IPAddress & |  | ) | const

noexcept

References IPAddress().

## operator>()

bool juce::IPAddress::operator> | ( | const IPAddress & |  | ) | const

noexcept

References IPAddress().

## operator<=()

bool juce::IPAddress::operator<= | ( | const IPAddress & |  | ) | const

noexcept

References IPAddress().

## operator>=()

bool juce::IPAddress::operator>= | ( | const IPAddress & |  | ) | const

noexcept

References IPAddress().

## getFormattedAddress()

String juce::IPAddress::getFormattedAddress | ( | const String & | unformattedAddress | ) |

static

Returns a formatted version of the provided IPv6 address conforming to RFC 5952 with leading zeros suppressed, lower case characters, and double-colon notation used to represent contiguous 16-bit fields of zeros.

Parameters

  unformattedAddress | the IPv6 address to be formatted

References getFormattedAddress().

Referenced by getFormattedAddress().

## isIPv4MappedAddress()

bool juce::IPAddress::isIPv4MappedAddress | ( | const IPAddress & | mappedAddress | ) |

static

Returns true if the given IP address is an IPv4-mapped IPv6 address.

References IPAddress(), and isIPv4MappedAddress().

Referenced by isIPv4MappedAddress().

## convertIPv4MappedAddressToIPv4()

IPAddress juce::IPAddress::convertIPv4MappedAddressToIPv4 | ( | const IPAddress & | mappedAddress | ) |

static

Converts an IPv4-mapped IPv6 address to an IPv4 address.

If the address is not IPv4-mapped, this will return a null address.

References convertIPv4MappedAddressToIPv4(), and IPAddress().

Referenced by convertIPv4MappedAddressToIPv4().

## convertIPv4AddressToIPv4Mapped()

IPAddress juce::IPAddress::convertIPv4AddressToIPv4Mapped | ( | const IPAddress & | addressToMap | ) |

static

Converts an IPv4 address to an IPv4-mapped IPv6 address.

References convertIPv4AddressToIPv4Mapped(), and IPAddress().

Referenced by convertIPv4AddressToIPv4Mapped().

## getInterfaceBroadcastAddress()

IPAddress juce::IPAddress::getInterfaceBroadcastAddress | ( | const IPAddress & | interfaceAddress | ) |

static

If the IPAdress is the address of an interface on the machine, returns the associated broadcast address.

If the address is not an interface, it will return a null address.

References getInterfaceBroadcastAddress(), and IPAddress().

Referenced by getInterfaceBroadcastAddress().

## Member Data Documentation

## address

uint8 juce::IPAddress::address[16]

The elements of the IP address.

Referenced by IPAddress().

## isIPv6

bool juce::IPAddress::isIPv6 = false

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited