HP-Socket is a set of common high-performance TCP/UDP Socket components, including server components, client components, and Agent components. It is widely used in TCP/UDP communication systems in various application scenarios, provides C/C ++, C #, Delphi, E (easy language), Java, Python, and other programming language interfaces. HP-Socket fully encapsulates the communication layer, and upper-layer applications do not need to pay attention to any details of the communication layer. HP-Socket provides an API Interface Based on The Event Notification model, it can be easily and efficiently integrated into new and old applications. In order to allow users to conveniently and quickly learn and use HP-Socket and quickly master the design ideas and usage of components, a large number of Demo examples have been carefully prepared, including the PUSH model, PULL model, and performance testing examples. HP-Socket is currently running on Windows and will be supported across platforms in the future.
----------------------------------------------------------------
Versatility
- The only responsibility of a communication component is to accept and send byte streams. It cannot participate in upper-layer protocol parsing.
- Decoupled from upper-layer users and independent from each other, components interact with users through the operation interface and listener interface, and the component implementation operation interface provides the upper-layer operation method; the user registers himself as the Listener of the component through the Listener interface to receive notifications from the component. Therefore, any user can use components as long as the listener interface is implemented. On the other hand, you can even re-write a component implementation method that is completely different for the user to call, as long as the component complies with the operation interface of the component, this is also the embodiment of the DIP design principles.
Availability
Availability is crucial to all common components. If it is too difficult to use, it is easier to rewrite it. Therefore, the Operation interfaces and listener interfaces of components are designed to be as simple as possible (in general, they are "dumbfounded"). There are no more than five main methods for these two interfaces. In addition, the component completely encapsulates all the underlying Socket communication, and the upper-layer applications do not see any communication details and do not have to intervene in any communication operations. The Socket Connection is abstracted as the Connection ID, this parameter is used as a connection identifier for upper-layer applications to identify different connections.
High Performance
As a general component at the underlying layer, performance issues must be considered and cannot be a bottleneck of the system. On the other hand, different Socket models are used according to the performance requirements of client components and server components. Components fully consider factors such as performance, actual use cases, availability, and implementation complexity to ensure that the performance requirements are not too complex. Make the following two design decisions:
- Client:Implement Socket communication and interaction in a separate thread to avoid interference with the main thread or other threads. Select the Event Select Communication Model for the I/O model. Each component object manages a Socket connection.
- Server:An efficient IOCP communication model is adopted. The cache pool technology usually requires frequent application and release of the memory buffer during communication, and a dynamic cache pool is established, A new object is created only when there are no available objects in the cache pool, and when there are too many cached objects, the cache pool is compressed. In addition, the dynamic memory of the component is allocated through the Private Heap mechanism, avoid competition with new/malloc and reduce memory holes.
- Agent:For application scenarios such as proxy servers or transit servers, the server itself also acts as a client to initiate large-scale connections to other servers. An Agent component manages multiple Socket connections and adopts the same technical architecture as the server, it can be used as a proxy server or a client part of a Transit server.
Scalability
You can set the performance parameters of the component according to the actual usage environment requirements (for example: the number of working threads, the size of various cache pools, the size of the sending and receiving buffer, the size of the Socket listening queue, the number of Accep distributions, and the interval of Heartbeat checks ).
(Project homepage: Click Here, click here)
* ** V3.2.1 update ***
> Added the TcpAgent/TcpPullAgent communication component:
-----------------
> Added HPSocket for Java SDK:
-----------------
> Optimize the data sending and receiving policies:
-----------------
> Other updates:
-----------------
> Upgrade description:
-----------------
* ** Update v3.1.3 ***
> Added demos for other languages:
-----------------
> Bug Fix:
-----------------
* ** V3.1.2 update ***
> Modify the trigger rule of the OnClose ()/OnError () event of the Server component:
-----------------
* ** V3.1.1 update ***
> Added the dynamic link library HPSocket4C. dll for exporting pure C functions:
-----------------
> Fully enable the Buffer Pool cache mechanism:
-----------------
* ** V3.0.2 update ***
> Compile HP-Socket as a dynamic link library:
-----------------
* ** V3.0.1 update ***
> Added the UDP communication component:
-----------------
> Code reconstruction and optimization:
-----------------