zhangmeng
2021-12-15 93ca5ec2e377961d0a7825b6906ee72dfc78480a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
= nng_sockaddr_in6(5)
//
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This document is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt).  A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//
 
== NAME
 
nng_sockaddr_in6 - IPv6 socket address
 
== SYNOPSIS
 
[source, c]
----
#include <nng/nng.h>
 
enum sockaddr_family {
    NNG_AF_INET6 = 4,
};
 
typedef struct {
    uint16_t sa_family;
    uint16_t sa_port;
    uint8_t  sa_addr[16];
    uint32_t sa_scope;
} nng_sockaddr_in6;
----
 
== DESCRIPTION
 
(((socket, address, IPv6)))
An `nng_sockaddr_in6` is the flavor of xref:nng_sockaddr.5.adoc[`nng_sockaddr`]
used to represent TCP (and sometimes UDP) addresses,
including the Internet Protocol (IP) address and port number.(((port number, TCP)))
 
This structure is used with IPv6 addresses.
A different structure, xref:nng_sockaddr_in.5.adoc[`nng_sockaddr_in`], is used
for IPv4 addresses.
 
The following structure members are present:
 
`sa_family`::
    This field will always have the value ((`NNG_AF_INET6`)).
 
`sa_port`::
    This field holds the TCP or UDP port number, in network byte-order.
    A zero value here is used when no specific port number is indicated.
 
`sa_addr`::
    This field holds the ((IP address))(((address, IPv6))) in
    network-byte order.
 
`sa_scope`::
    This is the scope, and is typically used with link local
    addresses to identify a specific interface.  The details of
    this are specific to the operating system.  This value is
    presented identically to the underlying system's, including
    any byte order considerations.
 
TIP: The `sa_port` and `sa_addr` fields are in network-byte order to
facilitate their use with system APIs such as `inet_ntop()`.
Most platforms use some form of BSD-derived network API, which uses
network-byte order in the various structures (such as `sockaddr_in6`).
 
IMPORTANT: This field appears similar to BSD `sockaddr_in6`, but it is
_not_ the same, and they may not be used interchangeably.
 
== SEE ALSO
 
[.text-left]
xref:nng_sockaddr.5.adoc[nng_sockaddr(5)],
xref:nng_sockaddr_in.5.adoc[nng_sockaddr_in(5)],
xref:nng_tcp.7.adoc[nng_tcp(7)],
xref:nng.7.adoc[nng(7)]