-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSocketWin.h
48 lines (33 loc) · 1022 Bytes
/
SocketWin.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
46
47
48
#pragma once
#include "Common.h"
#if EASY_WIN
#include "SocketBase.h"
EASY_NS_BEGIN
class SocketWin : public SocketBase {
public:
SocketWin();
virtual ~SocketWin();
virtual bool create(int protocol);
virtual void close(bool hasError = false);
virtual bool send(const char *buf, size_t len);
virtual int recv(char *buf, size_t len);
virtual void shutdown();
virtual bool bind(int port, const char *ip);
virtual bool bind(addrinfo *addrInfo);
virtual bool listen();
virtual bool accept(SockAddr *p = 0);
virtual bool connect(int port, const char *ip);
virtual bool connect(addrinfo *addrInfo);
// udp
virtual int sendto(const char *buf, size_t len, int port, const char *ip);
virtual int sendto(const char *buf, size_t len, addrinfo *addrInfo);
virtual int recvfrom(char *buf, size_t len, SockAddr **pp = 0);
virtual const char* formatError(int error);
protected:
virtual bool unblock();
virtual int getSockFd() { return sock; }
static int __inited;
SOCKET sock;
};
EASY_NS_END
#endif