cplusplus/networking-ts

Add integer_option helper

breese opened this issue · 3 comments

When using socket options that are not defined by [socket.opt], users have to create their own class that follows the GettableSocketOption [socket.reqmts.gettablesocketoption] or SettableSocketOption [socket.reqmts.settablesocketoption] concepts.

As the majority of socket options are integral, it would ease the burden of using such socket options if an integer_option helper class was available (basically the same as asio::detail::socket_option::integer.) Its use would boil down to:

using maximum_segment_size_type = net::integer_option<IPPROTO_TCP, TCP_MAXSEG>;
maximum_segment_size_type mtu;
socket.get_option(mtu);

A similar helper class for boolean socket options could also be added.

As with #52 I'll raise this as a comment against the PDTS.

I have such an helper class in my implementaton of this, but the template gets to be slightly more complicated:

template<int Level, int Name,
int v6Level=Level, int v6Name=Name,
int MinValue=std::numeric_limits::min(),
int MaxValue=std::numeric_limits::max()>
class integer_socket_option;

At least the "hops" options needs something like this.

This was submitted as a National Body comment against the PDTS, and discussed by the Library Evolution Working Group, see https://issues.isocpp.org/show_bug.cgi?id=302