Crow  1.1
A C++ microframework for the web
 
Loading...
Searching...
No Matches
tcp_socket_options.h
1#pragma once
2
3#ifdef CROW_USE_BOOST
4#include <boost/asio.hpp>
5#else
6#ifndef ASIO_STANDALONE
7#define ASIO_STANDALONE
8#endif
9#include <asio.hpp>
10#endif
11
12#include "crow/logging.h"
13
14namespace crow
15{
16#ifdef CROW_USE_BOOST
17 namespace asio = boost::asio;
18 using error_code = boost::system::error_code;
19#else
20 using error_code = asio::error_code;
21#endif
22 using tcp = asio::ip::tcp;
23
24 namespace detail
25 {
26 namespace socket
27 {
29 {
30 bool no_delay{false};
31 };
32
33 inline void apply_tcp_socket_options(tcp::socket& socket, const tcp_socket_options& options)
34 {
35 error_code ec;
36 socket.set_option(tcp::no_delay(options.no_delay), ec);
37 if (ec)
38 {
39 CROW_LOG_WARNING << "Failed to set TCP_NODELAY: " << ec.message();
40 }
41 }
42
43 template<typename Socket>
44 inline void apply_tcp_socket_options(Socket&, const tcp_socket_options&)
45 {
46 CROW_LOG_WARNING << "This socket type does not support set TCP_NODELAY option";
47 }
48 } // namespace socket
49 } // namespace detail
50} // namespace crow
The main namespace of the library. In this namespace is defined the most important classes and functi...
Definition tcp_socket_options.h:29