-
Notifications
You must be signed in to change notification settings - Fork 0
/
clientudp.h
42 lines (31 loc) · 866 Bytes
/
clientudp.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
/*
* Paweł Kapica, 334579
* Sieci Komputerowe
* Duże zadanie zaliczeniowe
*
*/
#ifndef CLIENTUDP_H
#define CLIENTUDP_H
#include "utils.h"
class ClientUDP
{
public:
ClientUDP(boost::asio::io_service& io_srv, std::string host);
void measure_latency();
bool finished();
private:
void handle_send(const boost::system::error_code& error, size_t bytes);
void start_receive();
void handle_receive(const boost::system::error_code& error, size_t bytes);
void handle_timeout(const boost::system::error_code& error);
bool finished_ = false;
boost::mutex mtx_;
uint64_t time_ = 0;
boost::asio::ip::udp::socket socket_;
boost::asio::ip::udp::endpoint endpoint_;
boost::asio::ip::udp::endpoint remote_endpoint_;
boost::asio::deadline_timer timer_;
boost::array<uint64_t, 1> send_buf_;
boost::array<uint64_t, 2> recv_buf_;
};
#endif //CLIENTUDP.H