blob: a4d7ec662ad6b925947ac58f187177eed419bffb [file] [log] [blame]
William A. Kennington III7d6fa422021-02-08 17:04:02 -08001#include "net_sockio.h"
2
3#include <sys/socket.h>
4#include <unistd.h>
5
6namespace net
7{
8
9int SockIO::close()
10{
11 int ret = 0;
12 if (sockfd_ >= 0)
13 {
14 ret = ::close(sockfd_);
15 sockfd_ = -1;
16 }
17
18 return ret;
19}
20
21int SockIO::write(const void* buf, size_t len)
22{
23 return ::write(sockfd_, buf, len);
24}
25
26int SockIO::recv(void* buf, size_t maxlen)
27{
28 return ::recv(sockfd_, buf, maxlen, 0);
29}
30
31SockIO::~SockIO()
32{
33 SockIO::close();
34}
35
36} // namespace net