mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
add some annotate
This commit is contained in:
parent
500c338d10
commit
277a679810
|
@ -9,6 +9,7 @@
|
|||
* I/O多路复用
|
||||
* 套接字编程
|
||||
* TCP协议
|
||||
* 事件循环
|
||||
|
||||
# 各文件的作用
|
||||
* **TcpModule.h**:定义了TCP模块的公共接口和数据结构,包括服务器和客户端参数结构体、回调函数类型等。
|
||||
|
|
|
@ -28,6 +28,9 @@ public:
|
|||
virtual ssize_t Write(const void *buf, const size_t bufLenght);
|
||||
virtual void Closed(void);
|
||||
};
|
||||
/**
|
||||
* @brief Verify that the header of the client object is legal.
|
||||
*/
|
||||
typedef struct i_tcp_client_header
|
||||
{
|
||||
const char *mCheckName;
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
#include "StatusCode.h"
|
||||
#include "TcpModule.h"
|
||||
#include <memory>
|
||||
/**
|
||||
* @brief Handle data interaction and connection state changes on established TCP connections.
|
||||
*/
|
||||
class ITcpClientAccept
|
||||
{
|
||||
public:
|
||||
|
@ -35,6 +38,9 @@ public:
|
|||
virtual void Init(void);
|
||||
virtual void UnInit(void);
|
||||
};
|
||||
/**
|
||||
* @brief Verify that the header of the server object is legal.
|
||||
*/
|
||||
typedef struct i_tcp_server_header
|
||||
{
|
||||
const char *mCheckName;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* @param io Socket handle
|
||||
* @param buf The transmitted data content
|
||||
* @param len
|
||||
* @param len Byte length of transmitted data
|
||||
*/
|
||||
static void on_message(hio_t *io, void *buf, int len)
|
||||
{
|
||||
|
@ -61,7 +61,6 @@ TcpClientImpl::TcpClientImpl(const TcpClientParam ¶m, const void *object) :
|
|||
}
|
||||
/**
|
||||
* @brief Initialize TCP clients, create event loops, I/O objects, and set callback functions for connection and closure.
|
||||
*
|
||||
*/
|
||||
void TcpClientImpl::Init(void)
|
||||
{
|
||||
|
@ -89,7 +88,6 @@ void TcpClientImpl::Init(void)
|
|||
}
|
||||
/**
|
||||
* @brief De-initialize the TCP client, close the I/O object and wait for the receiving thread to end.
|
||||
*
|
||||
*/
|
||||
void TcpClientImpl::UnInit(void)
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
private:
|
||||
std::mutex mMutex; ///A mutex lock used to synchronize access to shared resources.
|
||||
hloop_t *mLoop;
|
||||
hloop_t *mLoop; ///Event loop, listening for io objects
|
||||
hio_t *mIo; ///Socket handle
|
||||
const TcpClientParam mParam; ///Basic information of the client, including port, ip, reading and closing.
|
||||
std::thread mTcpClientThread;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* @brief Verify that object is a legitimate (existing) server.
|
||||
*
|
||||
* @param object Save the address of the character pointer variable.
|
||||
* Should be substituted into the private member objectThis of the client instance.
|
||||
* If the value of the character pointer pointed by *object is "tcp_server", return turn
|
||||
* @return true Indicates that the server exists.
|
||||
* @return false Indicates that the server does not exist
|
||||
|
@ -45,7 +46,7 @@ static bool TcpServerObjectCheck(void *object)
|
|||
* @brief Verify that object is a legitimate (existing) client.
|
||||
*
|
||||
* @param object Save the address of the character pointer variable.
|
||||
* The correct object is returned by the function NewTcpClient in Itcpclientlmpl.cpp file.
|
||||
*
|
||||
* @return true Indicates that the client exists.
|
||||
* @return false Indicates that the client does not exist
|
||||
*/
|
||||
|
|
|
@ -109,7 +109,7 @@ TcpServerImpl::TcpServerImpl(const TcpServerParam param) : mParam(param)
|
|||
void TcpServerImpl::Init(void)
|
||||
{
|
||||
constexpr int NO_FALGS = 0;
|
||||
mLoop = hloop_new(NO_FALGS);
|
||||
mLoop = hloop_new(NO_FALGS); ///Initialize event loop
|
||||
if (nullptr == mLoop) {
|
||||
LogError("hloop_new failed\n");
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue
Block a user