IPv6Address

IPv6 is the next-generation Internet Protocol version designated as the successor to IPv4, the first implementation used in the Internet that is still in dominant use currently.

More information: http://ipv6.com/

IPv6 supports 128-bit address space as opposed to 32-bit address space of IPv4.

IPv6 is written as 8 blocks of 4 octal digits (16 bit) separated by a colon (":"). Zero block can be replaced by "::".

For example:

1 0000:0000:0000:0000:0000:0000:0000:0001
2 is equal
3 ::0001
4 is equal
5 ::1
6 is analogue IPv4 127.0.0.1
7 
8 0000:0000:0000:0000:0000:0000:0000:0000
9 is equal
10 ::
11 is analogue IPv4 0.0.0.0
12 
13 2001:cdba:0000:0000:0000:0000:3257:9652
14 is equal
15 2001:cdba::3257:9652
16 
17 IPv4 address can be submitted through IPv6 as ::ffff:xx.xx.xx.xx,
18 where xx.xx.xx.xx 32-bit IPv4 addresses.
19 
20 ::ffff:51b0:ec6d
21 is equal
22 ::ffff:81.176.236.109
23 is analogue IPv4 81.176.236.109
24 
25 The URL for the IPv6 address will be of the form:
26 http://[2001:cdba:0000:0000:0000:0000:3257:9652]/
27 
28 If needed to specify a port, it will be listed after the
29 closing square bracket followed by a colon.
30 
31 http://[2001:cdba:0000:0000:0000:0000:3257:9652]:8080/
32 address: "2001:cdba:0000:0000:0000:0000:3257:9652"
33 port: 8080
34 
35 IPv6Address can be used as well as IPv4Address.
36 
37 scope addr = new IPv6Address(8080);
38 address: "::"
39 port: 8080
40 
41 scope addr_2 = new IPv6Address("::1", 8081);
42 address: "::1"
43 port: 8081
44 
45 scope addr_3 = new IPv6Address("::1");
46 address: "::1"
47 port: PORT_ANY
48 
49 Also in the IPv6Address constructor can specify the service name
50 or port as string
51 
52 scope addr_3 = new IPv6Address("::", "ssh");
53 address: "::"
54 port: 22 (ssh service port)
55 
56 scope addr_4 = new IPv6Address("::", "8080");
57 address: "::"
58 port: 8080

Constructors

this
this()
this
this(sockaddr* sa)
this
this(int port)

Create IPv6Address with zero address

this
this(const(char)[] addr, int port)

-port- can be PORT_ANY -addr- is an IP address or host name

this
this(const(char)[] addr, const(char)[] service)

-service- can be a port number or service name -addr- is an IP address or host name

Members

Functions

toString
string toString()

Properties

addr
ubyte[] addr [@property getter]
addressFamily
AddressFamily addressFamily [@property getter]
name
sockaddr* name [@property getter]
nameLen
int nameLen [@property getter]
port
ushort port [@property getter]
toAddrString
char[] toAddrString [@property getter]
toPortString
char[] toPortString [@property getter]

Structs

sockaddr_in6
struct sockaddr_in6

Variables

PORT_ANY
enum ushort PORT_ANY;
Undocumented in source.
sin
sockaddr_in6 sin;
Undocumented in source.

Inherited Members

From Address

sockaddr
struct sockaddr
Undocumented in source.
addrinfo
struct addrinfo
Undocumented in source.
name
sockaddr* name [@property getter]
Undocumented in source.
nameLen
int nameLen [@property getter]
Undocumented in source.
exception
void exception(immutable(char)[] msg)

Tango: added this common function

create
Address create(sockaddr* sa)

Address factory

resolve
Address resolve(const(char)[] host, const(char)[] service, AddressFamily af, AIFlags flags)
resolve
Address resolve(const(char)[] host, ushort port, AddressFamily af, AIFlags flags)
resolveAll
Address[] resolveAll(const(char)[] host, const(char)[] service, AddressFamily af, AIFlags flags)
resolveAll
Address[] resolveAll(const(char) host, ushort port, AddressFamily af, AIFlags flags)
passive
Address passive(const(char)[] service, AddressFamily af, AIFlags flags)
passive
Address passive(ushort port, AddressFamily af, AIFlags flags)
toAddrString
char[] toAddrString [@property getter]
toPortString
char[] toPortString [@property getter]
toString
string toString()
addressFamily
AddressFamily addressFamily [@property getter]

Examples

IPv6Address ia = new IPv6Address("7628:0d18:11a3:09d7:1f34:8a2e:07a0:765d", 8080);
assert(ia.toString() == "[7628:d18:11a3:9d7:1f34:8a2e:7a0:765d]:8080");
//assert(ia.toString() == "[7628:0d18:11a3:09d7:1f34:8a2e:07a0:765d]:8080");

Meta