blob: 6c499aa91469cb79278d931aed7bdb8fd828a641 (
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
|
/**
* \file mb_server.cpp
* \brief MessageBroker server.
* \author AKara
*/
#include "mb_server.hpp"
namespace NsMessageBroker
{
Server::Server(const std::string& address, uint16_t port)
{
m_sock = -1;
m_address = address;
m_port = port;
}
Server::~Server()
{
if(m_sock != -1)
{
Close();
}
}
int Server::GetSocket() const
{
return m_sock;
}
std::string Server::GetAddress() const
{
return m_address;
}
uint16_t Server::GetPort() const
{
return m_port;
}
bool Server::Bind()
{
m_sock = networking::bind(m_protocol, m_address, m_port, NULL, NULL);
return (m_sock != -1) ? true : false;
}
void Server::Close()
{
::close(m_sock);
m_sock = -1;
}
} /* namespace NsMessageBroker */
|