forked from awwit/httpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdapterDefault.cpp
More file actions
44 lines (34 loc) · 947 Bytes
/
AdapterDefault.cpp
File metadata and controls
44 lines (34 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "AdapterDefault.h"
namespace Socket
{
AdapterDefault::AdapterDefault(const Socket &_sock) noexcept : sock(_sock)
{
}
System::native_socket_type AdapterDefault::get_handle() const noexcept
{
return sock.get_handle();
}
::gnutls_session_t AdapterDefault::get_tls_session() const noexcept
{
return 0;
}
Adapter *AdapterDefault::copy() const noexcept
{
return new AdapterDefault(this->sock);
}
long AdapterDefault::nonblock_recv(void *buf, const size_t length, const std::chrono::milliseconds &timeout) const noexcept
{
return sock.nonblock_recv(buf, length, timeout);
}
long AdapterDefault::nonblock_send(const void *buf, const size_t length, const std::chrono::milliseconds &timeout) const noexcept
{
return sock.nonblock_send(buf, length, timeout);
}
void AdapterDefault::close() noexcept
{
// Wait for send all data to client
sock.nonblock_send_sync();
sock.shutdown();
sock.close();
}
};