-
Notifications
You must be signed in to change notification settings - Fork 3
/
WinsockWrapper.h
45 lines (26 loc) · 1.11 KB
/
WinsockWrapper.h
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
45
#pragma once
#include <memory>
#include "SocketWrapper.h"
#include <Winsock2.h>
#pragma comment(lib, "Ws2_32.lib")
class WinsockWrapper : public SocketWrapper
{
SOCKET socket_;
public:
WinsockWrapper(SOCKET socket);
static std::shared_ptr<SocketWrapper> createSocket(int af, int type, int protocol);
~WinsockWrapper();
int recv(char* buffer, size_t size, int flags) const override;
int recvNonBlocking(char *buffer, size_t size, int flags) const override;
int send(const char* buffer, size_t size, int flags) const override;
int setsockopt(int level, int optname, const char* optval, int optlen) const override;
int bind(const struct sockaddr* name, int namelen) const override;
int listen(int backlog) const override;
int close() const override;
std::shared_ptr<SocketWrapper> accept(sockaddr* addr, int* addrlen) const override;
bool valid() const override;
int lastError() const override;
char* lastErrorMsg() const override;
int connect(sockaddr* addr, int addrlen) const override;
int getsockname(sockaddr* addr, int* addrlen) const override;
};