chriskohlhoff / asio-tr2

C++ TR2 proposal based on Asio
17 stars 5 forks source link

basic_socket_acceptor::accept return clause unclear #206

Open jwakely opened 8 years ago

jwakely commented 8 years ago

Returns: If h is an open native socket, socket_type(ctx, s); otherwise socket_type(ctx).

What is s?

Should it be socket_type(ctx, protocl_, h) ?

The problem appears twice, in

socket_type accept(io_context& ctx);
socket_type accept(io_context& ctx, error_code& ec);

and

socket_type accept(io_context& ctx, endpoint_type& endpoint);
socket_type accept(io_context& ctx, endpoint_type& endpoint,
                   error_code& ec);

Also, for those latter overloads, should there be a requirement that endpoint.protocol() == protocol_ ?

chriskohlhoff commented 8 years ago

On 10 Oct 2015, at 4:09 am, Jonathan Wakely notifications@github.com wrote:

Returns: If h is an open native socket, socket_type(ctx, s); otherwise socket_type(ctx).

What is s?

Should it be sockettype(ctx, protocl, h) ?

Thanks, fixed in d4e7929eeef9f4ebdf7c2f8d8c7282f6719b8c2e. The problem affected asyncaccept too (missing protocol argument).

Also, for those latter overloads, should there be a requirement that endpoint.protocol() == protocol_ ?

On entry to the function, no. Those are output parameters e.g. in the case where you're using an IP socket, the protocol of the socket could be either IPv4 or v6, but the caller doesn't have to care.

On successful exit, yes, but I assume that specifying in terms of POSIX accept() covers that behaviour. Is that good enough?