(Created page with "== Server operations == A networking server typically listens for new connections from clients. Basic operation doesn't require any name resolution as the server can listen o...") |
|||
Line 27: | Line 27: | ||
</pre> | </pre> | ||
Note: | Note: <code>AI_PASSIVE</code> options ensures NULL nodename is translated to <code>::</code> and <code>0.0.0.0</code>. | ||
Note: You need to explicitly set <code>IPV6_V6ONLY</code> socket option on all IPv6 sockets to avoid conflict between an IPv4 and an IPv6 socket. | Note: You need to explicitly set <code>IPV6_V6ONLY</code> socket option on all IPv6 sockets to avoid conflict between an IPv4 and an IPv6 socket. |
Revision as of 10:29, 12 October 2015
Server operations
A networking server typically listens for new connections from clients. Basic operation doesn't require any name resolution as the server can listen on wildcard addresses.
Address list generation phase
Many servers support listening on specific local IPv4 and IPv6 addresses. It is especially useful for running multiple instances on one host but it is also used as a security measuer for example to limit scope to the local host. Although configuration typically includes literal addresses, it may be useful to use actual domains names like localhost or even those from DNS provided that they are immediately resolvable using the local infrastructure.
Typical configuration situations:
- no configuration – server listens on
::
and0.0.0.0
- localhost – server listens on
::1
and127.0.0.1
- list of domain names or literal IP addresses – server listens on listed or resolved IP addresses
Known issues:
- Fedora by default enables dual-stack sockets on
::0
address and therefore explicit listening on both wildcard addresses doesn't work as intended.
Query using getaddrinfo()
struct addrinfo hints = { .ai_flags = AI_PASSIVE }; struct addrinfo *res; int status; status = getaddrinfo(nodename, servname, &hints, &res);
Note: AI_PASSIVE
options ensures NULL nodename is translated to ::
and 0.0.0.0
.
Note: You need to explicitly set IPV6_V6ONLY
socket option on all IPv6 sockets to avoid conflict between an IPv4 and an IPv6 socket.
Binding and listening phase
Server should listen on all addresses from the previous phase.
How to test
TODO