forked from taganaka/SpeedTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpeedTestClient.h
40 lines (36 loc) · 1.03 KB
/
SpeedTestClient.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
//
// Created by Francesco Laurita on 5/30/16.
//
#ifndef SPEEDTEST_SPEEDTESTCLIENT_H
#define SPEEDTEST_SPEEDTESTCLIENT_H
#include <ctime>
#include <netdb.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#include <chrono>
#include <unistd.h>
#include "SpeedTest.h"
#include "DataTypes.h"
class SpeedTestClient {
public:
explicit SpeedTestClient(const ServerInfo &serverInfo);
~SpeedTestClient();
bool connect();
void close();
bool ping(long &millisec);
bool download(const long size, const long chunk_size, long &millisec);
bool upload(const long size, const long chunk_size, long &millisec);
float version();
const std::pair<std::string, int> hostport();
private:
bool mkSocket();
ServerInfo mServerInfo;
int mSocketFd;
float mServerVersion;
static bool readLine(int &fd, std::string &buffer);
static bool writeLine(int &fd, const std::string &buffer);
};
typedef bool (SpeedTestClient::*opFn)(const long size, const long chunk_size, long &millisec);
#endif // SPEEDTEST_SPEEDTESTCLIENT_H