forked from skyfireitdiy/sflib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsf_tcp_client_win.h
54 lines (37 loc) · 1.05 KB
/
sf_tcp_client_win.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
49
50
51
52
53
54
/**
* @version 1.0.0
* @author skyfire
* @mail [email protected]
* @see http://github.com/skyfireitdiy/sflib
* @file sf_tcp_client_win.h
* sflib第一版本发布
* 版本号1.0.0
* 发布日期:2018-10-22
*/
#pragma once
#include <winsock2.h>
#include <string>
#include <functional>
#include <memory>
#include <thread>
#include "sf_tcp_client_interface.h"
namespace skyfire
{
class sf_tcp_client : public sf_tcp_client_interface
{
private:
bool raw__ = false;
bool inited__ = false;
SOCKET sock__ = INVALID_SOCKET;
public:
SOCKET get_raw_socket() override;
bool bind(const std::string& ip, unsigned short port) override;
sf_tcp_client(bool raw = false);
static std::shared_ptr <sf_tcp_client> make_client(bool raw = false);
~sf_tcp_client();
bool connect_to_server(const std::string &ip, unsigned short port) override;
bool send(int type, const byte_array &data) override;
bool send(const byte_array & data) override;
void close();
};
}