blob: 07697dbde7e2e0b0ad1d001223d7abe1d3ce4bb4 (
plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
|
/**
* \file mb_tcpclient.hpp
* \brief MessageBroker TCP client.
* \author AKara
*/
#ifndef MB_TCPCLIENT_H
#define MB_TCPCLIENT_H
#include <iostream>
#include "mb_client.hpp"
/**
* \namespace NsMessageBroker
* \brief MessageBroker related functions.
*/
namespace NsMessageBroker
{
/**
* \class TcpClient
* \brief MessageBroker TCP client.
*/
class TcpClient : public Client
{
public:
/**
* \brief Constructor.
* \param address remote network address or FQDN
* \param port remote local port
*/
TcpClient(const std::string& address, uint16_t port);
/**
* \brief Destructor.
*/
virtual ~TcpClient();
/**
* \brief Receive data from the network.
* \param data if data is received it will put in this reference
* \return number of bytes received or -1 if error
* \note This method will blocked until data comes.
*/
virtual ssize_t Recv(std::string& data);
/**
* \brief Send data.
* \param data data to send
* \return number of bytes sent or -1 if error
*/
ssize_t Send(const std::string& data);
};
} /* namespace NsMessageBroker */
#endif /* MB_TCPCLIENT_H */
|