Implemented ODS protocol.
[bpdyndnsd] / src / tcp_service.h
CommitLineData
6650af14
BS
1/** @file
2 * @brief TCPService class header. This class represents a TCP client.
3 *
4 *
5 *
6 * @copyright Intra2net AG
7 * @license GPLv2
8*/
9
10#ifndef TCPSERVICE_H
11#define TCPSERVICE_H
12
13#include "logger.h"
14
15#include <boost/shared_ptr.hpp>
16#include <boost/asio.hpp>
17#include <boost/asio/ssl.hpp>
18
19typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> SSLStream;
20
21class TCPService : public IPService
22{
23
24private:
25
26 boost::shared_ptr<SSLStream> Socket;
27 // IOService has to be a member, otherwise the socket.close() operation will throw "mutex: Invalid argument"
28 // Bug in boost::asio ? Cause no docs found concerning this issue. The socket.close() operation is trying to clean up io_service.
29 boost::asio::io_service IOService;
30
31public:
32
33 typedef boost::shared_ptr<TCPService> Ptr;
34
35 TCPService();
36
37 ~TCPService();
38
39 virtual int connect(const std::string& _hostname, const std::string& _port) throw (boost::system::system_error);
40
41 std::string read_from_socket() throw (boost::system::system_error);
42
43 int write_to_socket(const std::string& data) throw (boost::system::system_error);
44
45 int close() throw (boost::system::system_error);
46};
47
48#endif