December 2018
Intermediate to advanced
552 pages
12h 18m
English
The client logic for this example is a combination of the debug examples in previous chapters (which we have been building upon) and the previous TCP example.
We start by defining the debug level and enable macros, as with previous examples:
#ifdef DEBUG_LEVELconstexpr auto g_debug_level = DEBUG_LEVEL;#elseconstexpr auto g_debug_level = 0;#endif#ifdef NDEBUGconstexpr auto g_ndebug = true;#elseconstexpr auto g_ndebug = false;#endif
The client class is identical to the client class in the previous TCP example:
class myclient{ int m_fd{}; struct sockaddr_in m_addr{};public: explicit myclient(uint16_t port) { if (m_fd = ::socket(AF_INET, SOCK_STREAM, 0); m_fd == -1) { throw std::runtime_error(strerror(errno)); } m_addr.sin_family ...Read now
Unlock full access