High-performance TCP/UDP/HTTP communication framework HP-Socket v4.0.1 released

HP-Socket

  HP-Socket is a set of general high-performance TCP/UDP/HTTP communication framework, including server components, client components and Agent components. It is widely used in TCP/UDP/HTTP communication systems in various application scenarios. C++, C#, Delphi, E (easy language), Java, Python and other programming language interfaces. HP-Socket fully encapsulates the communication layer, and applications do not need to pay attention to any details of the communication layer; HP-Socket provides an API interface based on an event notification model, which can be easily and efficiently integrated into old and new applications.

  In order to allow users to learn and use HP-Socket easily and quickly, and quickly grasp the design ideas and usage methods of the framework, a large number of Demo examples (such as: PUSH model example, PULL model example, PACK model example, performance test example ) are carefully produced. and other programming language examples). HP-Socket currently runs on the Windows platform, and will implement cross-platform support in the future.

  "HP-Socket v4.0 Development Guide"

----------------------------------------------------------------

Versatility

  • The only responsibility of HP-Socket is to receive and send byte streams, and it does not participate in the application's protocol parsing and other work.
  • HP-Socket interacts with applications through interfaces and is completely decoupled. Any application can integrate HP-Socket seamlessly as long as it implements the interface specification of HP-Socket.

Ease of use

  • Ease of use is crucial for all general-purpose frameworks. If it's too difficult to use, it's more convenient to write one yourself. Therefore, the interface of HP-Socket is designed to be very simple and uniform.
  • HP-Socket completely encapsulates all low-level communication details, and applications do not have to and cannot interfere with low-level communication operations. The communication connection is abstracted as the Connection ID, and the Connection ID is provided as the unique identification of the connection to the application to handle different connections.
  • HP-Socket provides receiving models such as PUSH / PULL / PACK. Applications can flexibly choose to process encapsulation and unpacking in manual, semi-automatic or fully automatic ways. The PULL / PACK receiving model can greatly reduce the complexity of encapsulation and unpacking processing. Reduce the chance of error.

high performance

  • Client component: Based on the Event Select communication model, communication operations are performed in a separate thread to avoid mutual interference with the main thread or other threads. Each component object manages a Socket connection.
  • Server component: Based on the IOCP communication model, combined with technologies such as buffer pools and private heaps, it supports ultra-large-scale connections and achieves efficient memory management in high concurrency scenarios.
  • Agent component: For application scenarios such as proxy server or transit server, the server itself also acts as a client to initiate large-scale connections to other servers. An Agent component object can manage multiple Socket connections at the same time; the Agent component and the Server component use the same technical architecture. A client component that can be used as a proxy server or a relay server.

Scalability

  The application can adjust various performance parameters of HP-Socket (such as the number of worker threads, size of the buffer pool, sending mode and receiving mode, etc.) according to different capacity requirements, communication scale and resource conditions, etc., and optimize resource allocation , while meeting application requirements without wasting resources excessively.

   (Project homepage: click here , download address: click here )


*** v4.0.1 update ***

 > Add HTTP series communication components:

-----------------

  1. New HTTP Server components
    1) Component class: CHttpServer, CHttpsServer
    2) Implementation interface: ITcpServer / IComplexHttpResponder
    3) Listener interface: IHttpServerListener
  2. New HTTP Agent components
    1) Component class: CHttpAgent, CHttpsAgent
    2) Implementation interface: ITcpAgent / IComplexHttpRequester
    3) Listener interface: IHttpAgentListener
  3. New HTTP Client components
    1) Component class: CHttpClient, CHttpsClient
    2) Implementation interface: ITcpClient / IHttpRequester
    3) Listener interface: IHttpServerListener
  4. Added HTTP example Demo
    1) TestEcho-Http (source code)
    2) TestEcho-Http-4C (4C LIB / 4C DLL)
  5. Http listener
    1) Listener event:
    OnMessageBegin() : [optional] start parsing
    OnRequestLine() : [Optional] Request line parsing completed (only for HTTP server)
    OnStatusLine() : [Optional] Status line parsing completed (only for HTTP clients)
    OnHeader() : [optional] request header notification
    OnHeadersComplete() : [Required] Request header completion notification
    OnBody() : [Required] Request body message notification
    OnChunkHeader()		: 【可选】Chunked 报文头通知
    OnChunkComplete()	: 【可选】Chunked 报文结束通知
    OnMessageComplete()	: 【必须】完成解析通知
    OnUpgrade()		: 【可选】升级协议通知
    OnParseError()		: 【必须】解析错误通知
    2) 监听器事件返回值(EnHttpParseResult
    HPR_OK		: 继续解析
    HPR_SKIP_BODY	: 跳过当前请求 BODY(仅用于 OnHeadersComplete 事件)
    HPR_UPGRADE	: 升级协议(仅用于 OnHeadersComplete 事件)
    HPR_ERROR	: 终止解析,断开连接

 > 组件接口调整:

-----------------

  1. IServer 和 IAgent 组件的所有监听器回调方法增加‘事件源’参数,如:OnShutdown() -> OnShutdown(T* pSender)
  2. IClient 组件的所有监听器回调方法增加‘连接ID’参数,如:OnHandShake(IClient* pClient) -> OnHandShake(T* pSender, CONNID dwConnID)
  3. IServer 和 IAgent 接口增加接口方法: Get/SetMaxConnectionCount() 用于设置最大连接数,最大连接数默认:10000
  4. OnHandShake() 事件触发规则调整:非 SSL 组件在 OnConnect() 事件后也触发 OnHandShake() 事件,使 SSL 组件和 SSL 组件处理流程一致
  5. HPSocket4C 增加 PACK 组件监听器的创建、销毁方法,新版本必须使用下列方法创建、销毁 PACK 组件监听器:
    1) Create_HP_TcpPackServerListener / Destroy_HP_TcpPackServerListener
    2) Create_HP_TcpPackAgentListener / Destroy_HP_TcpPackAgentListener
    3) Create_HP_TcpPackClientListener / Destroy_HP_TcpPackClientListener
  6. SSL 组件支持 SNI
    1) SSL 初始化方法 HP_SSL_Initialize(),增加 SNI 回调函数指针参数
    2) 新增方法 HP_SSL_AddServerContext(),用于 加载 SNI 主机证书

 > 其他更新:

-----------------

  1. IServer 和 IAgent 组件采用 Ring Pool 取代 R/W Lock + Map 维护活动连接,提升读写和并发性能
  2. 更新所有 Demo 示例代码

*** v3.5.1更新 ***

 > 增加 SSL 系列通信组件:

-----------------

  1. 新增 SSL PUSH 组件:CSSLServer、CSSLAgent、CSSLClient
  2. 新增 SSL PULL 组件:CSSLPullServer、CSSLPullAgent、CSSLPullClient
  3. 新增 SSL PACK 组件:CSSLPackServer、CSSLPackAgent、CSSLPackClient
  4. SSL Server 实现 ITcpServer 接口,SSL Agent 实现 ITcpAgent 接口,SSL Client 实现 ITcpClient 接口
  5. 启动 SSL 通信组件前需要调用 HP_SSL_Initialize() 函数初始化 SSL 全局环境参数
  6. 通信结束后调用 HP_SSL_Cleanup() 函数清理 SSL 全局运行环境
  7. 新增 SSL 相关示例 Demo:
    1) TestEcho-SSL		(源代码)
    2) TestEcho-SSL-Pack	(DLL / 4C DLL)
    3) TestEcho-SSL-4C	(4C LIB)
    4) TestEcho-SSL-PFM	(LIB)

> 组件接口调整:

-----------------

  1. ITcpServerListener 接口增加 SSL 握手成功事件:OnHandShake(CONNID dwConnID)
  2. ITcpAgentListener 接口增加 SSL 握手成功事件:OnHandShake(CONNID dwConnID)
  3. ITcpClientListener 接口增加 SSL 握手成功事件:OnHandShake(IClient* pClient)
  4. 枚举类型 EnSocketError 增加‘SSL 环境未就绪’错误代码 SE_SSL_ENV_NOT_READY 
  5. 增加枚举类型:EnSSLSessionMode(SSL 工作模式),EnSSLVerifyMode(SSL 验证模式) 
  6. HPSocket-SSL DLL 主要头文件:SocketInterface-SSL.h,HPSocket-SSL.h
  7. HPSocket4C-SSL DLL 主要头文件:HPSocket4C-SSL.h
  8. Tcp Pack 系列组件可设置的最大包长调整为 4194303/0x3FFFFF 字节
  9. Tcp Pack 系列组件的有效包头标识取值范围调整为 0 ~ 1023/0x3FF

> 增加静态库工程:

-----------------

  1. 新增项目工程 HPSocketLIB 和 HPSocketLIB4C 用于编译 HPSocket 和 HPSocket4C 静态库
  2. 静态库与动态库的使用方式一致(请参考示例 Demo:TestEcho-SSL-4C 和 TestEcho-SSL-PFM)
  3. 使用 HPSocket 或 HPSocket4C 静态库时,需要在工程属性中定义预处理宏 -> HPSOCKET_STATIC_LIB
  4. 静态库目标文件不包含在发布包中(因为太大),如果需要请自行编译

*** v3.4.4更新 ***

 > 增加 Tcp Pack 系列通信组件:

-----------------

  1. Tcp Pack 系列组件保证每个 OnReceive 事件都向应用程序提供一个完整数据包
  2. Tcp Pack 系列组件是 PUSH/PULL 模式的结合体,应用程序不必处理分包(如:PUSH)与数据抓取(如:PULL)
  3. Tcp Pack 系列组件提供 Get/SetMaxPackSize() 和 Get/SetPackHeaderFlag() 方法,用来设置最大包长和包头标识
  4. CTcpPackServer 实现 ITcpServer 接口,CTcpPackAgent 实现 ITcpAgent 接口,CTcpPackClient 实现 ITcpClient 接口

> 组件接口调整:

-----------------

  1. OnClose/OnError 合并为一个通信事件: OnClose(CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode)
  2. 枚举类型 EnSocketOperation 增加一个枚举值: SO_CLOSE = 5,标识关闭 Socket 操作
  3. IServer 和 IAgent 接口删除接口方法: Get/SetRecvPolicy()
  4. IServer 和 IAgent 接口删除接口方法: Get/SetMaxShutdownWaitTime()

> Bug 修复:

-----------------

  1. Fix TCP Pack Agent "Async connection failure caused program crash" bug
  2. Fixed CCASQueue of vc-common-src common code package may cause infinite loop bug

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327085136&siteId=291194637