hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
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
#ifndef DOMAIN_TCP_CLIENT_H
#define DOMAIN_TCP_CLIENT_H
 
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
 
#include <string>
 
#include "logger/log.h"
 
#ifdef __ANDROID__
    #define LOCAL_SOCKET_PATH "/dev/socket/camera_tool"
#endif
 
#define SERVER_PORT 5543
#define UNIX_DOMAIN "/tmp/UNIX.domain"
 
using namespace std;
 
class DomainTCPClient
{
  private:
    int sock;
    std::string address;
    int port;
    struct sockaddr_un server;
 
  public:
    DomainTCPClient();
    virtual ~DomainTCPClient();
    bool Setup(string domainPath);
    bool Send(string data);
    int Send(char* buff, int size);
    string Receive(int size);
    int Receive(char* buff, int size);
    void Close();
};
 
#endif