-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClient.h
57 lines (45 loc) · 1020 Bytes
/
Client.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
55
///////////////////////////////////////////////////////////////////
// Prepared for BCIT ELEX4618, April 2022, by Craig Hennessey
///////////////////////////////////////////////////////////////////
#pragma once
#include <string>
#include <opencv2/opencv.hpp>
#define WIN4618
//#define PI4618
#ifdef WIN4618
#include "Winsock2.h"
#endif
#ifdef PI4618
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
typedef int SOCKET;
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <thread>
#endif
class CClient
{
private:
#ifdef WIN4618
WSADATA _wsdat;
#endif
int _port;
std::string _addr;
SOCKET _socket;
bool setblocking(SOCKET fd, bool blocking);
public:
CClient();
~CClient();
void connect_socket(std::string addr, int port);
void close_socket();
void tx_str(std::string str);
bool rx_str(std::string &str);
bool rx_im(cv::Mat &im);
};