33 lines
724 B
C++
33 lines
724 B
C++
#pragma once
|
|
|
|
#include <boost/asio.hpp>
|
|
#include <functional>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "boost/bind.hpp"
|
|
#include "protocol.hpp"
|
|
|
|
namespace commons {
|
|
|
|
class client {
|
|
public:
|
|
client(boost::asio::io_service& io_service,
|
|
const boost::asio::ip::address& multicast_address,
|
|
short multicast_port, unsigned short tcp_port);
|
|
|
|
template <typename BufferType, typename HandlerFunc>
|
|
void send(const BufferType& buffer, HandlerFunc handler) {
|
|
socket_.async_send_to(buffer, endpoint_, handler);
|
|
}
|
|
|
|
private:
|
|
boost::asio::ip::udp::endpoint endpoint_;
|
|
boost::asio::ip::udp::socket socket_;
|
|
std::string message_;
|
|
unsigned short port_;
|
|
};
|
|
|
|
} // namespace commons
|