1 #pragma once 2 3 #include <sys/types.h> 4 5 namespace net 6 { 7 8 class SockIO 9 { 10 public: 11 SockIO() = default; 12 explicit SockIO(int sockfd) : sockfd_{sockfd} 13 {} 14 virtual ~SockIO(); 15 16 int get_sockfd() const 17 { 18 return sockfd_; 19 } 20 21 virtual int write(const void* buf, size_t len); 22 23 virtual int close(); 24 25 virtual int recv(void* buf, size_t maxlen); 26 27 protected: 28 int sockfd_ = -1; 29 }; 30 31 } // namespace net 32