summaryrefslogtreecommitdiffstats
path: root/Master/Masterarbeit/src/XorayaPluginExecutor/TcpServer.h
blob: d62a4808483f43c0fd0fe1ae61deb2def9d0f21b (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
/*!
 * \file TcpServer.h
 * \author S. Eisenhauer
 * \date 27.10.2011
 * \brief Header of CTcpServer
 */
#ifndef CTCPSERVER_H_
#define CTCPSERVER_H_

#include <boost/asio.hpp>
#include "TcpConnection.h"

class CPluginExecutor;

/// tcp server on target
class CTcpServer
{
public:
	/// constructor
	/// \param[in] pxExecutor pointer to main application
	/// \param[in] io_service reference to io_service
	/// \param[in] port TCP port to listen on
    CTcpServer(CPluginExecutor* pxExecutor,boost::asio::io_service& io_service, int32_t port);
    
    /// destructor
    ~CTcpServer(void);
    
    /// handle accept on a connection
    /// \param[in] pNewCon Pointer to new connection object
    /// \param[in] error error code on the connection
    void vAcceptHandler(CTcpConnection::tConnectionPtr pNewCon, const boost::system::error_code& error);
    
    /// stop the server
    void vStop();
    
    /// get the io_service
    boost::asio::io_service& xGetIoService()
    {
    	return m_xIoService;
    }
	void vUploadLogMessage(const tstLogMessage& stLogMsg);
private:
    boost::asio::ip::tcp::acceptor m_xAcceptor;
    CPluginExecutor* m_pxExecutor;
    boost::asio::io_service& m_xIoService;
    void vStartAccept();
};
#endif /*CTCPSERVER_H_*/