Encapsulates a complete IPv6 address.
More...
#include <rw/network/RWInet6Addr.h>
Encapsulates a complete IPv6 address that includes type information, host, port, and scope.
- Example
Encapsulates a complete IPv6 address.
Definition RWInet6Addr.h:59
◆ RWInet6Addr() [1/6]
RWInet6Addr::RWInet6Addr |
( |
| ) |
|
Constructs an address for an IPv6 Internet connection. The constructor that takes only a port argument creates a special address used to bind to any of the network interfaces on the machine on which the process is running. This is done, for example, when you are setting a server address. An address created using the default constructor binds to an arbitrary port number on any network interface on the local machine. These constructors do not block.
◆ RWInet6Addr() [2/6]
RWInet6Addr::RWInet6Addr |
( |
const RWInetPort & | port | ) |
|
Constructs an address for an IPv6 Internet connection. The constructor that takes only a port argument creates a special address used to bind to any of the network interfaces on the machine on which the process is running. This is done, for example, when you are setting a server address. An address created using the default constructor binds to an arbitrary port number on any network interface on the local machine. These constructors do not block.
◆ RWInet6Addr() [3/6]
RWInet6Addr::RWInet6Addr |
( |
int | port | ) |
|
Constructs an address for an IPv6 Internet connection. The constructor that takes only a port argument creates a special address used to bind to any of the network interfaces on the machine on which the process is running. This is done, for example, when you are setting a server address. An address created using the default constructor binds to an arbitrary port number on any network interface on the local machine. These constructors do not block.
◆ RWInet6Addr() [4/6]
RWInet6Addr::RWInet6Addr |
( |
const RWInetPort & | port, |
|
|
const RWInet6Host & | host, |
|
|
unsigned | scope = 0, |
|
|
short | type = SOCK_STREAM, |
|
|
short | protocol = 0 ) |
Constructs an address for an IPv6 Internet connection. The constructor that takes only a port argument creates a special address used to bind to any of the network interfaces on the machine on which the process is running. This is done, for example, when you are setting a server address. An address created using the default constructor binds to an arbitrary port number on any network interface on the local machine. These constructors do not block.
◆ RWInet6Addr() [5/6]
RWInet6Addr::RWInet6Addr |
( |
const sockaddr_in6 & | addr, |
|
|
short | type = SOCK_STREAM, |
|
|
short | protocol = 0 ) |
Constructs an address for an IPv6 Internet connection. The constructor that takes only a port argument creates a special address used to bind to any of the network interfaces on the machine on which the process is running. This is done, for example, when you are setting a server address. An address created using the default constructor binds to an arbitrary port number on any network interface on the local machine. These constructors do not block.
◆ RWInet6Addr() [6/6]
RWInet6Addr::RWInet6Addr |
( |
const RWCString & | s | ) |
|
Constructs an address from the ASCII string s, where s has the form type:host%scope:port
. type
, host
, and scope
are optional. If type is supplied, it must be stream
for a stream socket address, or dgram
for a datagram socket. host
should be wrapped in square brackets ('['
and ']'
) if the string should contain an IPv6 hex address. scope
is only required if its value is nonzero. If not specified, type
defaults to a value of stream
, host
to a value of "ANY"
and scope
to a value of 0
.
◆ addressType()
virtual RWSockType RWInet6Addr::addressType |
( |
| ) |
const |
|
virtual |
◆ as()
◆ asSockaddr()
virtual sockaddr * RWInet6Addr::asSockaddr |
( |
| ) |
const |
|
virtual |
Returns a pointer to an internal representation of the address that was cast to a sockaddr
structure, as defined by the sockets and TLI APIs. (TLI is the UNIX System V network communication interface.) The pointer is to an internal data structure, so it becomes invalid if self is changed in any way or goes out of scope. If the address has no representation as a sockaddr
, a null
pointer is returned.
Implements RWSockAddrBase.
◆ getHost()
Returns the host portion of the address.
◆ getPort()
Returns the port portion of the address.
◆ getScope()
unsigned RWInet6Addr::getScope |
( |
| ) |
const |
|
inline |
Returns the scope portion of the address.
◆ id()
virtual RWCString RWInet6Addr::id |
( |
unsigned | level = 0 | ) |
const |
|
virtual |
Returns a string describing self. The verbosity of the output is controlled by level, where level=0
is the most basic output, and level=9
is the most verbose.
Grammar Definitions
type ::= <the result of addressType().id(level)>
host-value ::= <the result of getHost().id(level)>
hostname ::= host-value | See Note Below
port ::= <the result of getPort().id(level)>
scope-value ::= <the result of getScope() if non-zero>
scope ::= "%" scope-value
- Note
When the result of RWInet6Host::id() is interpreted by RWInet6Addr::id(), the grammar of RWInet6Host is updated as follows:
host ::= hostname | '[' ip-address ']'
The extra '[' and ']' isolate the ':' that are a part of the address from the ':' delimiter used in RWInet6Addr's representation.
level | Calls prepare() | Output Grammar | Sample Output for id(level) given RWInet6Addr(80, "::1") |
0 | | hostname (scope)? ":" port | [::1]:80 |
1 | | hostname (scope)? ":" port | [::1]:80 |
2 | | type ":" hostname (scope)? ":" port | inet6:stream:[::1]:80 |
3 | X | hostname (scope)? ":" port | server.example.com:80 |
4 | X | hostname (scope)? ":" port | server.example.com(::1):80(http) |
5 | X | hostname (scope)? ":" port | server.example.com(::1):80(http) |
6 | X | type ":" hostname (scope)? ":" port | inet6:stream:server.example.com:80 |
7 | X | type ":" hostname (scope)? ":" port | inet6:stream:server.example.com(::1):80(http) |
8 | X | type ":" hostname (scope)? ":" port | inet6:stream:server.example.com(::1):80(http) |
9 | X | type ":" hostname (scope)? ":" port | inet6:stream:server.example.com(::1):80(http,www,www-http) |
Implements RWSockAddrBase.
◆ is()
◆ operator!=()
bool RWInet6Addr::operator!= |
( |
const RWInet6Addr & | rhs | ) |
const |
◆ operator==()
bool RWInet6Addr::operator== |
( |
const RWInet6Addr & | rhs | ) |
const |
◆ prepare()
virtual void RWInet6Addr::prepare |
( |
| ) |
const |
|
virtual |
Ensures that future calls do not block on this address. If necessary, this function looks up the IP address and port number from the host name and service name. It is not necessary to call prepare(), but if you don't, future calls may block. No exceptions are thrown from prepare().
Reimplemented from RWSockAddrBase.
◆ sockaddrSize()
virtual size_t RWInet6Addr::sockaddrSize |
( |
| ) |
const |
|
virtual |
Returns the size of an internal representation of the socket address defined by the sockets.
Implements RWSockAddrBase.
◆ operator>>()
std::istream & operator>> |
( |
std::istream & | , |
|
|
RWInet6Addr & | ) |
|
related |
Reads a representation of addr from strm. The representation should be of the form produced by id() with level=2
.