In boost.asio, there is a class called an acceptor. The acceptor is used to listen for connection requests on a specific endpoint and open a socket in response to a request.
There are three acceptor constructors I am interested in.
- construct an
acceptorwithout opening or binding
explicit basic_socket_acceptor(
const executor_type & ex);
- construct an
acceptorand open it
basic_socket_acceptor(
const executor_type & ex,
const protocol_type & protocol);
- construct an
acceptor, open it, and bind it to an endpoint
basic_socket_acceptor(
const executor_type & ex,
const endpoint_type & endpoint,
bool reuse_addr = true);
1 and 3 both make sense. 1 constructs the acceptor in the C++ sense: allocate memory on the stack, maybe initialize some variables, etc. 3 specifies the endpoint that the acceptor should listen on. Incoming connection requests addressed to the endpoint will be accepted and a connection will be created on a new socket. 2, however, appears to be a middle ground that allows you to set a "protocol type."
I want to say that that "2 allows you to specify more member variables (the protocol) than 1 and less member variables (e.g., IP address and port number) than 3." However, I don't know if it does anything "extra" over setting some member variables (does it engage with the OS or the NIC?).
What does it mean to open an acceptor?