Encapsulation and Process Analysis of Delphi-iocp API code

Source: Internet
Author: User

After a period of research and study, I have a certain understanding of the iocp principles and procedures. The test demo results show that about 5000 connections can be easily processed in the LAN, it is still relatively stable. Several hours after running the echo test. The server memory is stable at about 60 MB.

In the past two days, the original code is encapsulated into an iocp class.

The original API call is good for studying and learning iocp principles. It may be hard to understand if there are no good documents after encapsulation.

 

 

1. Data Transmission Flowchart

 

 

 

 

2. Service write-back data process

 

 

2. iocp object Center

 

2.1 tiocpobject
In the iocp object center, create an iocp handle and enable the listener port.
It can process data, receive sockets, send and receive requests, and send requests.

 

2.2 tiocpclientcontext
Socket extensions
Receives data,
It can inherit its datarecvied for data processing.
You can call it to write data back to the client.

2.3 tiocpclientcontextfactory
Creates and releases socket extension objects <used when receiving client connections>
Registers encoder and decoder
Registers the socket extension object class <class that inherits tiocpclientcontext>

 

2.4 tiocpdecoder
The decoder called after receiving data from the client decodes the received data stream into an object.
You can handle the sticking package here.
You need to register the decoder with tiocpclientcontextfactory

 

2.5 tiocpencoder
When tiocpclientcontext is called to write back an object to the client, it is encoded as a data stream. Then it is sent to tiocpobject for data delivery.
Register the encoder with tiocpclientcontextfactory

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.