Universal high-performance Windows Socket component HP-socket v2.2.2 officially released

Source: Internet
Author: User



HP-socket is a set of universal high-performance Windows Socket component packages, including the server component (iocp model) and the client component (event select model). It is widely used in Windows TCP 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) A test echo-PFM and a test echo-pull are two test examples, quickly grasp the design ideas and usage of components.

* HP-socket Official Website: http://www.jessma.org
* HP-socket: https://code.google.com/p/ldcsaa/

----------------------------------------------------------------
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 ).

Update record:
* ** V2.2.2 update ***
> Optimize the functions of Heartbeat Detection:
-----------------
* Change the get/setkeepalivetimes () method of iserversocket and iclientsocket to get/setkeepalivetime ()
* The default KeepAliveTime attribute of ciocpserver and cclientsocket is changed to 5000.
* The default keepaliveinterval attribute of ciocpserver and cclientsocket is changed to 3000.

* ** V2.2.1 update ***
> PULL model support:
-----------------
* Added the PULL model data receiving and notification method onreceive (dwconnid, INT) to the isocketlistener)
* Added the pull socket interface ipullsocket. The fetch (dwconnid, pbuffer, ilength) method of this interface is used to capture communication data.
> Server:
-----------------
* The isocketserver interface is changed to iserversocket.
* Added the pull server socket listener abstract class cpullserversocketlistener.
* Added the pull server socket interface ipullserversocket.
* Added the pull server socket implementation class ciocppullserver
> Client:
-----------------
* The client socket interface isocketclient is renamed iclientsocket
* The client socket implementation class csocketclient is renamed cclientsocket
* Added the pull client socket listener abstract class cpullclientsocketlistener.
* Added the pull client socket interface ipullclientsocket.
* Added the pull client socket implementation class cpullclientsocket.
> Other updates:
-----------------
* Added the pull socket test program testecho-pull.
* Add some help structs to sockethelper. H (. cpp ).
> Upgrade description:
-----------------
* Applications using HP-socket v2.1.1 can be securely upgraded to v2.2.1.
* Because the names of isocketserver, isocketclient, and csocketclient have been modified, the application needs to modify the referenced names and header file names accordingly.

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.