Advertisement
Vlad3955

userver.h

Oct 5th, 2022
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #pragma once
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <cstdlib>
  5. #include <iomanip>
  6. #include <iostream>
  7. #include <string>
  8.  
  9. #include "socket_wrap.h"
  10.  
  11. // Trim from end (in place).
  12. static inline std::string& rtrim(std::string& s)
  13. {
  14.     s.erase(std::find_if(s.rbegin(), s.rend(), [](int c) { return !std::isspace(c); }).base());
  15.     return s;
  16. }
  17.  
  18. class UDPServer
  19. {
  20. public:
  21.     UDPServer(unsigned short port);
  22.     void listenUDP();
  23.     ~UDPServer();
  24. private:
  25.     socket_wrapper::Socket m_sock;
  26.     socket_wrapper::SocketWrapper m_sock_wrap;
  27.     unsigned short m_port;
  28.     struct sockaddr_in m_client_address;
  29.     socklen_t m_client_address_len;
  30.     ssize_t m_recv_len;
  31. };
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement