HP-Socket

    HP-Socket is a common set of high-performance TCP / UDP Socket components, including server components, client components and Agent components, widely used in a variety of different scenarios of TCP / UDP communications system ,and provides C / C + +, C #, Delphi, E (easy language), Java, Python and other programming language interfaces. HP-Socket achieves complete encapsulation of the communication layer , the upper application layer does not have to follow the details of the communication; HP-Socket API provides an interface based on event notification model,which can be very simple and efficient built into old and new applications. To allow users to learn and use HP-Socket quickly and easily,and grasp design ideas and use components quickly ,there are a large number of Demo examples, including PUSH model examples, PULL model examples , performance test sample and so on. HP-Socket is currently running on the Windows platform, but in the future it will support cross-platform.
 
Versatility
The only responsibility of communication component is to accept and transmit byte stream, absolutely not participate in the upper protocol analysis ,etc;
Decouple the users with the uppe, and do not rely on each other .The components interact with the user through the user interface and the listener interface. Component interface provides methods of operation to achieve operation for the upper; use interface to achieve the listener registered for yourselves as components Listener and receive Components notice. Therefore, any user simply implements the listener interface to be use components; the other hand, one can even re-write their own implementations of components to achieve a completely different call to the user, as long as the components follow the operation interface of the components, which is the DIP design reflects principles.
Availability
Availability for all common components is vital.It is more convenient to write a new one when its hard to use. Therefore, the operation of the component interface and listener interface designed to be simple to use (it is just like a popular word “fool operation”), these two interfaces have no more than five main methods. In addition, all of the components completely encapsulate the underlying Socket Communications, the upper application can not see the details of any communication, and do not interfere with any communication operations. Socket connection is abstracted as Connection ID, which identifies the parameter as a connection to the upper application to identify different connections .
High performance
As the underlying common components, performance issues must be considered.It must not become the bottleneck of the system. On the other hand, from reality, using different models based on performance requirements Socket client components and server components. Components are designed to take full account of the performance of real-world usage scenarios, availability ,implementation complexity and other factors,0that ensure that it meets the performance requirements while its not writed too complicated. Design decisions made following two points:
  • Client:
Implementing Socket Communications is in a separate thread and interact with the main thread to avoid mutual interference or other threads. I / O model Select Event Select communication model. Each component object management a Socket connection.
  • Server:
IOCP using efficient communication model; use buffer pool technology: in the process of communication,when it requires frequent application and releases memory buffer,it needs the establishment of a dynamic buffer pool. Only when the pool is not available to create a new object caching object, and when too much object cache, the buffer pool is compressed; In addition, dynamic memory component by assigning private heap (Private Heap) mechanism to avoid the new / malloc competition while reducing the memory hole.
  • Agent:
For a proxy server or server applications such as transit scenario, the server itself as a client initiates a large-scale connections to other servers, an Agent Component Object Socket manages multiple connections and server architecture using the same technology can be used as a proxy server transit or client server components.
Flexibility
According to the actual use of the environment it required to set the component performance parameters (such as: the number of worker threads, various buffer pool size, the size of the receive buffer, Socket listen queue size, number Accep distributed and checks the heartbeat interval etc.).