embedded-framework/utils/TcpModule/readme.md
2024-08-02 22:37:34 +08:00

34 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# TCP模块
这个项目实现了一个用于网络通信的TCP模块提供了服务器和客户端功能。
在网络编程中套接字socket是一个用于网络通信的端点。在客户端和服务器模型中客户端会创建一个套接字来与服务器建立连接而服务器则监听来自客户端的连接请求。一旦连接建立客户端和服务器就可以通过各自的套接字进行数据的发送和接收。
# 涉及的知识
* 网络通信
* 多线程处理
* 回调函数
* C++/C
* I/O多路复用
* 套接字编程
* TCP协议
* 事件循环
# 各文件的作用
* **TcpModule.h**定义了TCP模块的公共接口和数据结构包括服务器和客户端参数结构体、回调函数类型等。
* **TcpModule.cpp**实现了TcpModule.h中定义的接口包括创建和释放TCP服务器和客户端的函数。
* **ITcpClient.h/ITcpClient.cpp**定义和实现了TCP客户端接口包括初始化、读取数据、写入数据和关闭连接等虚函数。
* **ITcpServer.h/ITcpServer.cpp**定义和实现了TCP服务器接口包括初始化、关闭服务器等虚函数。
* **TcpClientImpl.h/TcpClientImpl.cpp**实现了ITcpClient接口是TCP客户端的具体实现。
* **TcpServerImpl.h/TcpServerImpl.cpp**实现了ITcpServer接口是TCP服务器的具体实现。
* **TcpModuleMakePtr.h/TcpModuleMakePtr.cpp**提供了创建TCP服务器和客户端实例的工厂方法。
* **TcpServerHandle.h/TcpServerHandle.cpp**管理TCP服务器的实例提供了添加和获取服务器实例的方法。
* **TcpClientAcceptImpl.h/TcpClientAcceptImpl.cpp**实现了ITcpClientAccept接口处理客户端连接的接受和数据交换。