High-performance Socket component HP-Socket v3.1.3 officially released

Source: Internet
Author: User

HP-Socket is a set of high-performance Windows Socket components. It provides server components (IOCP model) and client components (Event Select model). It is widely used in Windows TCP/UDP communication systems. 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 various applications. In addition, in order to make it easier for everyone to learn HP-Socket, we have carefully produced a function Test example (Test Echo) test Echo-PFM, Test Echo-PULL, and Test Echo-UDP ), you can use these test examples to quickly understand the design ideas and usage of components.

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

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 interaction in a separate thread. This avoids interference with the main thread or other threads. Select the Event Select Communication Model for the I/O model.
  • Server: The IOCP communication model with the highest efficiency on the Windows platform 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.

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)

* ** Update v3.1.3 ***

> Added demos for other languages:

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

> Bug Fix:

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

> Upgrade description:

-----------------
  1. You can use HP-Socket v3.1.2 and earlier applications to securely upgrade to HP-Socket v3.1.3.

* ** 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:

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

  1. Standardize the naming of all interfaces, classes, and code files
  2. Refactoring and optimization of a large number of component code
  3. Server components are added with a read/write lock mechanism to effectively balance processing performance and security
  4. The Socket object cache list of the server component sets the lock time to improve access security.

* ** V2.2.3 update ***

 > Change the data type of the connection ID to 'connid ':

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

  1. Define the CONNID data type in SocketHelper. h (default: typedef ULONG_PTR CONNID)
  2. Applications can define CONNID as the expected type (for example, ULONG/ULONGLONG)
  3. To facilitate transplantation and maintenance, the connection ID should be referenced anywhere in the Application

> The Socket component on the server supports binding additional data to each connection:

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

  1. IServerSocket and CIocpServer add method Get/SetConnectionExtra ()
  2. Through the above two methods, the application can bind any additional data for each connection and obtain the data

* ** V2.2.2 update ***

 > Optimize the functions of Heartbeat Detection:

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

  1. Change the Get/SetKeepAliveTimes () method of IServerSocket and IClientSocket TO Get/SetKeepAliveTime ()
  2. The default KeepAliveTime attribute of CIocpServer and CClientSocket is changed to 5000.
  3. The default KeepAliveInterval attribute of CIocpServer and CClientSocket is changed to 3000

* ** V2.2.1 update ***

> PULL model support:

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

  1. Added the PULL model data receiving and notification method OnReceive (dwConnID, int) to the ISocketListener)
  2. Added the PULL Socket interface IPullSocket. The Fetch (dwConnID, pBuffer, iLength) method of this interface is used to capture communication data.

> Server:

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

  1. The server Socket interface ISocketServer is renamed IServerSocket
  2. Added the PULL Server Socket listener abstract class CPullServerSocketListener.
  3. Added the PULL Server Socket interface IPullServerSocket
  4. Added the PULL Server Socket implementation class CIocpPullServer

> Client:

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

  1. The client Socket interface ISocketClient is renamed IClientSocket
  2. The client Socket implementation class CSocketClient is renamed CClientSocket
  3. Added the PULL Client Socket listener abstract class CPullClientSocketListener.
  4. Added the PULL Client Socket interface IPullClientSocket.
  5. Added the PULL Client Socket implementation class CPullClientSocket

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.