zhangzengfei
2020-07-30 512cae0fd797fac428f07d9d955f880e9ee353c1
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
#ifndef TCP_CLIENT_H
#define TCP_CLIENT_H
 
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netdb.h> 
#include <vector>
 
using namespace std;
 
class TCPClient
{
  private:
    int sock;
    std::string address;
    int port;
    struct sockaddr_in server;
 
  public:
    TCPClient();
    bool setup(string address, int port);
    bool Send(string data);
    string receive(int size = 4096);
    string read();
    void exit();
};
 
#endif