Boost logo

Boost :

From: Arvid Norberg (arvid.norberg_at_[hidden])
Date: 2019-11-01 15:10:53


Here's an example of hot to set "custom" socket options (i.e. other than
those supported by boost asio).

struct exclusive_address_use
{
  explicit exclusive_address_use(int enable): m_value(enable) {}
  template<class Protocol> int level(Protocol const&) const { return
SOL_SOCKET; }
  template<class Protocol> int name(Protocol const&) const { return
SO_EXCLUSIVEADDRUSE; }
  template<class Protocol> int const* data(Protocol const&) const { return
&m_value; }
  template<class Protocol> size_t size(Protocol const&) const { return
sizeof(m_value); }
  int m_value;
};

On Fri, Nov 1, 2019 at 11:10 AM JH via Boost <boost_at_[hidden]> wrote:

> On 11/1/19, JH <jupiter.hce_at_[hidden]> wrote:
> > Hi,
> >
> > I tried to use setsockopt(socket_fd, SOL_TCP, TCP_USER_TIMEOUT,
> > &tcpTimeout, sizeof(int)) to set up TCP_USER_TIMEOUT, but stuck with
> > the boost::asio::ssl::stream<boost::asio::ip::tcp::socket>, how could
> > I get socket file handler number from the boost asio socket?
>
> I should say the socket file descriptor.
>
> > Thank you.
> >
> > Kind regards,
> >
> > - jh
> >
> > On 10/31/19, JH <jupiter.hce_at_[hidden]> wrote:
> >> Hi,
> >>
> >> I am using boost asio TCP socket in my device application for network
> >> connection in Linux platform.
> >>
> >> I am troubled currently by long TCP tmeout issues in a device to
> >> switch application between WiFi and 4G LTE.
> >>
> >> If my application TCP was connected via 4G LTE initially, when WiFi is
> >> available, the network is switched to WiFi, but the application TCP
> >> connection would have 30 minutes timeout before it terminated the 4G
> >> LTE and reconnects to WiFi. That 30 minutes is too long.
> >>
> >> I checked TCP document for TCP_USER_TIMEOUT:
> >>
> >> TCP_USER_TIMEOUT
> >> Decreasing user timeouts allows applications to "fail fast", if so
> >> desired. Otherwise, failure may take up to 20 minutes with the
> >> current system defaults in a normal WAN environment.
> >>
> >> My question is, in boost asio socket, is there an API to change
> >> TCP_USER_TIMEOUT?
> >>
> >> Appreciate if showing an example or point me to a document how to do it.
> >>
> >> Thank you.
> >>
> >> Kind regards,
> >>
> >> - jh
> >>
> >
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

-- 
Arvid Norberg

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk