Line 46: | Line 46: | ||
== How to test == | == How to test == | ||
TODO | TODO: Test connection, logging, access lists and related stuff. |
Revision as of 09:55, 14 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.
Accepting clients phase
A dual-stack server accepts connections from clients of both protocols. It often needs to cope with both types of addresses for logging and access control purposes.
Related library calls:
accept()
getsockname()
How to test
TODO: Test connection, logging, access lists and related stuff.