Sample of a TcpServer. More...
#include <TcpServer.h>
Public Types | |
| enum class | Option { NoReusePort = 0 , ReusePort = 1 } |
| using | ThreadInitCallback = std::function<void(EventLoop*)> |
| using | ConnectionMap = std::unordered_map<std::string, TcpConnectionPtr> |
Public Member Functions | |
| TcpServer (const InetAddress &listenAddress, Option option=Option::NoReusePort) | |
| Constructor Function. | |
| virtual | ~TcpServer () |
| Destructor Function. | |
| TcpServer (const TcpServer &)=delete | |
| Copy Constructor Function. | |
| TcpServer & | operator= (const TcpServer &)=delete |
| Copy Assignment Operation. | |
| void | SetThreadInitCallback (const ThreadInitCallback &cb) |
| Set Thread initialize Call back. | |
| void | AddConnectionCallback (const DelegateConnectionCallback::Agent &cb) |
| Add Connection Call back. | |
| void | AddMessageCallback (const DelegateMessageCallback::Agent &cb) |
| Add Message Call back. | |
| void | AddWriteCompleteCallback (const DelegateWriteCompleteCallback::Agent &cb) |
| Add WriteComplete Call back. | |
| void | Start (int threadSize) const |
| Start ThreadPool and call listen on acceptor. | |
Private Member Functions | |
| void | NewConnection (SOCKET socketFd, const InetAddress &peerAddress) |
| Handle New Connection to Acceptor. | |
| void | RemoveConnection (const TcpConnectionPtr &connection) |
| Remove a TcpConnection. | |
| void | RemoveConnectionInLoop (const TcpConnectionPtr &connection) |
| Remove a TcpConnection InLoop. | |
Private Attributes | |
| std::string | m_IpPort |
| TcpServer Ip and Port. | |
| std::unique_ptr< Acceptor > | m_Acceptor |
| Acceptor. | |
| std::shared_ptr< EventLoopThreadPool > | m_ThreadPool |
| ThreadPool. | |
| DelegateConnectionCallback | m_ConnectionCallback |
| ConnectionCallback. | |
| DelegateMessageCallback | m_MessageCallback |
| MessageCallback. | |
| DelegateWriteCompleteCallback | m_WriteCompleteCallback |
| WriteCompleteCallback. | |
| ThreadInitCallback | m_ThreadInitCallback |
| ThreadInitCallback. | |
| int | m_NextConnectedId |
| Next Connection id. | |
| ConnectionMap | m_Connections |
| All TcpConnections. | |
Sample of a TcpServer.
Definition at line 28 of file TcpServer.h.