2 #include <boost/thread.hpp> 3 #include <boost/asio.hpp> 4 #include <boost/noncopyable.hpp> 5 #include <boost/scoped_ptr.hpp> 6 #include <boost/asio/steady_timer.hpp> 7 #include "NPLConnectionManager.h" 8 #include "NPLDispatcher.h" 27 void start(
const char* server=NULL,
const char* port=NULL);
78 bool IsKeepAliveEnabled();
87 bool IsIdleTimeoutEnabled();
91 int GetIdleTimeoutPeriod();
101 void SetMaxPendingConnections(
int val);
114 void handle_resolve_local(
const boost::system::error_code& err, boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
117 void handle_accept(
const boost::system::error_code& e);
123 void handle_idle_timeout(
const boost::system::error_code& err);
126 boost::asio::io_service m_io_service_dispatcher;
129 boost::scoped_ptr<boost::thread> m_dispatcherThread;
132 boost::asio::ip::tcp::resolver m_resolver;
135 boost::asio::ip::tcp::acceptor m_acceptor;
141 NPLConnection_ptr m_new_connection;
149 bool m_bTCPKeepAlive;
155 bool m_bEnableIdleTimeout;
158 bool m_bIsServerStarted;
161 int m_nIdleTimeoutMS;
164 int m_nMaxPendingConnections;
167 typedef boost::asio::basic_waitable_timer<boost::chrono::steady_clock> timer_type;
168 timer_type m_idle_timer;
173 boost::scoped_ptr<boost::asio::io_service::work> m_work_lifetime;
int GetMaxPendingConnections() const
queue size of the acceptor's queue.
Definition: NPLNetServer.cpp:393
void EnableAnsiMode(bool bEnable)
whether the first line of the NPL protocol is in ansi code page.
Definition: NPLNetServer.cpp:383
void SetKeepAlive(bool bEnable)
enable application level keep alive.
Definition: NPLNetServer.cpp:67
virtual const std::string & GetHostIP()
get the host IP of this NPL runtime
Definition: NPLNetServer.cpp:354
define this to enable debugging of NPL code in visual studio
Definition: INPL.h:9
void start(const char *server=NULL, const char *port=NULL)
start the server's io_service loop.
Definition: NPLNetServer.cpp:121
void SetTCPKeepAlive(bool bEnable)
System level Enable/disable SO_KEEPALIVE.
Definition: NPLNetServer.cpp:50
this class serves as an interface between the low level socket interface and NPL message queues...
Definition: NPLDispatcher.h:23
virtual bool IsServerStarted()
whether the NPL runtime's http server is started.
Definition: NPLNetServer.cpp:359
CNPLConnectionManager & GetConnectionManager()
get the connection object in this server
Definition: NPLNetServer.h:42
bool IsTCPKeepAliveEnabled()
whether SO_KEEPALIVE is enabled.
Definition: NPLNetServer.cpp:61
void SetIdleTimeoutPeriod(int nMilliseconds)
how many milliseconds of inactivity to assume this connection should be timed out.
Definition: NPLNetServer.cpp:92
Current NPL configuration settings.
Definition: NPLNetServer.h:16
CNPLDispatcher & GetDispatcher()
NPLDispatcher serves as an interface between the low level socket interface and NPL message queues...
Definition: NPLNetServer.h:38
virtual const std::string & GetHostPort()
get the host port of this NPL runtime
Definition: NPLNetServer.cpp:349
NPLConnection_ptr CreateConnection(NPLRuntimeAddress_ptr pAddress)
Create a new connection with a remote server and immediately connect and start the connection...
Definition: NPLNetServer.cpp:369
void Cleanup()
clean up all resources
Definition: NPLNetServer.cpp:364
std::string GetExternalIP()
get extern IP address of this computer.
Definition: NPLNetServer.cpp:325
void EnableIdleTimeout(bool bEnable)
Enable idle timeout.
Definition: NPLNetServer.cpp:82
void stop()
Stop the server.
Definition: NPLNetServer.cpp:185
All incoming and outgoing connection sessions.
Definition: NPLConnectionManager.h:13