The invention provides a communication method based on a coroutine mechanism. The communication method based on the coroutine mechanism comprises the following steps that firstly, in a main thread circulation process, a socket is monitored; secondly, whether data is input into the socket or not is judged, and the third step is executed if yes; thirdly, the input data is subjected to decoding analysis, whether the input data is request data or response data is judged, the fourth step is executed if the data is request data, and the fifth step is executed if the data is response data; fourthly, a coroutine function is established and used for processing the request data; fifthly, a coroutine function corresponding to the response data is searched for according to the response data, and the coroutine function is switched to process the response data. By means of the communication method based on the coroutine mechanism, the problem of waiting in a blockage mode can be solved, and data access conflict in multi-thread implement can be avoided.