ebusd_send added.

TCPListener renamed to TCPServer.
TCPClient added.
This commit is contained in:
Roland Jax
2014-06-02 18:58:19 +02:00
parent 9e6ba69f70
commit bc7b4d91b0
8 changed files with 149 additions and 22 deletions
+9 -10
View File
@@ -117,13 +117,12 @@ void* Connection::run()
Network::Network(const bool localhost) : m_listening(false), m_running(false)
{
// Start Listener
if (localhost == true)
m_Listener = new TCPListener(A.getParam<int>("p_port"), "127.0.0.1");
m_Server = new TCPServer(A.getParam<int>("p_port"), "127.0.0.1");
else
m_Listener = new TCPListener(A.getParam<int>("p_port"), "0.0.0.0");
m_Server = new TCPServer(A.getParam<int>("p_port"), "0.0.0.0");
if (m_Listener && m_Listener->start() == 0)
if (m_Server && m_Server->start() == 0)
m_listening = true;
}
@@ -141,7 +140,7 @@ Network::~Network()
if (m_running == true)
stop();
delete m_Listener;
delete m_Server;
}
void* Network::run()
@@ -157,10 +156,10 @@ void* Network::run()
FD_ZERO(&checkfds);
FD_SET(m_notify.notifyFD(), &checkfds);
FD_SET(m_Listener->getFD(), &checkfds);
FD_SET(m_Server->getFD(), &checkfds);
(m_notify.notifyFD() > m_Listener->getFD()) ?
(maxfd = m_notify.notifyFD()) : (maxfd = m_Listener->getFD());
(m_notify.notifyFD() > m_Server->getFD()) ?
(maxfd = m_notify.notifyFD()) : (maxfd = m_Server->getFD());
for (;;) {
fd_set readfds;
@@ -186,8 +185,8 @@ void* Network::run()
}
// new data from socket
if (FD_ISSET(m_Listener->getFD(), &readfds)) {
TCPSocket* socket = m_Listener->newSocket();
if (FD_ISSET(m_Server->getFD(), &readfds)) {
TCPSocket* socket = m_Server->newSocket();
if (socket == NULL)
continue;
+1 -1
View File
@@ -72,7 +72,7 @@ public:
private:
std::list<Connection*> m_connections;
WQueue<Message*>* m_queue;
TCPListener* m_Listener;
TCPServer* m_Server;
Notify m_notify;
bool m_listening;
bool m_running;