Delphi Winsock Non-blocking mode detailed

Source: Internet
Author: User

Delphi Winsock non-blocking mode detailed
 
Winsockt the Tclientsocket setting of the ClientType property is ctnonblocking. The communication mode is non-blocking mode. Ctblocking is blocking mode, here are some differences between blocking and non-blocking. Ctblocking mode when the client requests the data, the thread blocks not to continue until the server returns the data, the client executes as needed, and reads the data. However, the defect of blocking mode is still relatively large, it often causes the program to die or feign death. When the server sends a large file, the blocking mode is basically discarded, because the data buffer is small, can not get the data in time, blocking mode will think that the data is sent, will break the service connection, resulting in data transmission failure. Therefore, the congestion mode comparison is suitable for the network unobstructed, and the data volume is small situation.   Non-blocking mode when a client sends a connection request and open, it does not execute the subsequent request, even if the requested data is not sent, but instead executes both connect and write events, and there should be a connecting event in between. Connect is the event after a successful connection, and write is the event that prepares to send the request. All of our sending requests will be executed in the write event. When we execute in the Write event, the read event is called, and in the Read event we will accept the data sent by the server, and if the amount of data is large, the read event will be called until the data is sent. Non-blocking mode is suitable for situations where the data volume is large.   Blocking mode is different from non-blocking mode, but according to my personal view, the non-blocking mode has a greater advantage over blocking mode, both in terms of performance and data integrity. So in my development is also the use of non-blocking mode     This is reproduced content, the source is: http://www.2cto.com/kf/201302/191918.html, only for learning needs, more offended

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.