-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpeedTestClient.h
More file actions
46 lines (39 loc) · 1.35 KB
/
Copy pathSpeedTestClient.h
File metadata and controls
46 lines (39 loc) · 1.35 KB
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
#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();
bool ping(long &millisec);
bool upload(long size, long chunk_size, long &millisec);
bool download(long size, long chunk_size, long &millisec);
float version();
const std::string& versionString();
bool versionAtLeast(const std::string& minimum);
// Dotted versions are compared component by component: "2.11" is newer
// than "2.3", which a plain float comparison gets backwards.
static bool versionAtLeast(const std::string& version, const std::string& minimum);
const std::pair<std::string, int> hostport();
void close();
private:
bool mkSocket();
ServerInfo mServerInfo;
int mSocketFd;
float mServerVersion;
std::string mServerVersionString;
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