High-performance communication model-network communication I/O mode (Windows)

Source: Internet
Author: User


#Socket事件 >fd_connect: >fd_accept is usually triggered when the socket API function is called by the client socket: The event that typically occurs on the server side > The Network transport service process is going to the socket Window (csocketwnd, message Pool) sends Wm_socket_notify notifications
The network service process, CSocket (WSock32.dll), Socket API (ws2_32.dll) hierarchies are as follows:



#阻塞模式
Blocking communication Model (server), the traffic between server and client in blocking mode is synchronized when the Fd_accept event is received by the Serer side, blocking is only contacted

#非阻塞模式
> in non-blocking mode, the client and server communication is in an asynchronous state > function call immediately after the return, when the network operation is sent by the Winsock to the application to send a message notification operation completed, at this time can be based on the message parameters sent to determine whether the operation is normal. > Non-blocking mode eliminates the need to create a new thread compared to blocking mode





#选择I/o mode (SELECT)
By invoking Select, the system can wait for multiple IO devices at the same time. Select hangs when no device is ready, and any one of the devices is ready, and select returns.

#异步模型
#异步和同步 > synchronization, when a function call is made, the call does not return > async until the result is obtained, and when an asynchronous procedure call is made, the caller cannot immediately get the result of the call, but instead notifies the caller by state, notification, and callback. > by checking the status to determine the result of an asynchronous call, the efficiency is very low, because you need periodic check status > Callback functions and Notifications almost
#同步调用与阻塞调用 > For synchronous calls, the current thread is still active. For example, the receive function is called in CSocket, and while the buffer has no data, the function waits and does not return, but the thread continues to process various messages. > The current thread is suspended for blocking calls. For example, the REVC function, when the socket is working in blocking mode, if the function is called with no data in the buffer, then the thread will be suspended until there is data.
#非阻塞非阻塞, the function does not block the current thread until the result is not available, but returns immediately. > Whether the object is in blocking mode and the function is not blocking calls have a strong interest, but not one by one corresponding > blocking objects can have non-blocking invocation, can be through the API polling state, when appropriate call blocking function, you can avoid blocking. > For non-blocking objects, special calls can also enter blocking calls, such as the Select>csocket::receive function (synchronous) >recv (blocking)















From for notes (Wiz)

High-performance communication model-network communication I/O mode (Windows)

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.