1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253module juptune.event.io;
struct IpAddress
{
/++ FUNCTIONS ++/
/// The raw IPv4 address in network order.
uint asIpv4();
/// The raw IPv6 address in network order.
ubyte[16LU] asIpv6();
///
void asSocketAddr(sockaddr* used, ulong usedLength, sockaddr_in ipv4, sockaddr_in6 ipv6);
///
static IpAddress fromSocketAddr(const sockaddr* addr);
/// Returns: The Kind of IP stored.
IpAddress.Kind kind();
///
static IpAddress mustParse(const const char[] address, ushort defaultPort = cast(ushort)0u);
/// Parses an IPv4 or IPv6 address string into an IpAddress object.
static Result parse(IpAddress ip, const const char[] address, ushort defaultPort = cast(ushort)0u);
/// Converts the current address into an IPv6 address.
IpAddress toIpv6();
///
void toString(Sink)(Sink sink, bool withPort = true);
/// Creates a copy of this IpAddress with the given port.
IpAddress withPort(ushort port);
/++ ENUMS ++/
/// Result error enum
enum Error : int
{
///
none = 0,
/// The given IP string was in an unsupported format, or maybe it's just completely incorrect.
invalidAddress = 1
}
/// Which IP version the address is for.
enum Kind : int
{
///
FAILSAFE = 0,
///
ipv4 = 2,
///
ipv6 = 10
}
/++ VARIABLES ++/
/// The port represented by the IP address. A value of 0 can mean either "explicit 0" or "no port was provided".
nothrow @nogc ushort port;
}
Non-IO helper structs
Describe and IP address. Supports IPv4 and IPv6.
| Name | Description |
|---|---|
| Error |
|
| Kind |
Which IP version the address is for. |
| Name | Description |
|---|---|
| asIpv4 |
The raw IPv4 address in network order. |
| asIpv6 |
The raw IPv6 address in network order. |
| asSocketAddr | |
| fromSocketAddr | |
| kind |
Returns: The |
| mustParse | |
| parse |
Parses an IPv4 or IPv6 address string into an |
| toIpv6 |
Converts the current address into an IPv6 address. |
| toString | |
| withPort |
Creates a copy of this |
| Name | Description |
|---|---|
| port |
The port represented by the IP address. A value of 0 can mean either "explicit 0" or "no port was provided". |