================================== Declaration ==================================
This article is original, reproduced in the text of the influential annotated author and source, and to ensure the integrity of the article.
Do not modify (including this statement) without the consent of the author, and reserve the right of legal investigation.
Do not use for publication, printing or academic reference without the consent of the author.
In order to ensure the correct contents, we suggest that we should read the original text.
This article link: http://www.cnblogs.com/wlsandwho/p/4238531.html
=======================================================================
Write a serial communication of small things, because the next machine colleagues only used 2, 3, 5 pins, so only custom protocol to simulate link detection.
=======================================================================
Originally wanted to use GetTickCount, with Send time, receive time, time interval, by adding subtraction to indicate the status of the current connection.
But feel too troublesome, good trouble ah, really trouble, do not believe yourself to try.
Therefore, the spirit of "lazy lazy can not lazy way to lazy" principle, I decided to find another road.
=======================================================================
Art comes from life.
Think of English as "past", "now complete", "now complete" these statements, a little (this is a function word) thought, thought of a plan.
=======================================================================
Use 0 to indicate not connected
Use 1 to indicate that you are connected
Use 2, 3, 4, 5 、......、 N to indicate currently connected, stateful detection
Well, that would be a good run.
From 0 to 1 means connection
From 1 to 2 indicates currently connected, stateful detection is in progress
From 2 to 3 indicates that the connection is currently connected, stateful detection has been performed, but no response, resume status detection.
......
When a response is received, change n from the current value to 1, indicating that the connection
When a specified value is exceeded, the connection is treated as disconnected, and N is changed from the current value to 0
=======================================================================
So it is very important to learn English and Chinese.
================================ Disgrace Wall ===================================
Http://www.cnblogs.com/wlsandwho/p/4206472.html
Problem solving-Simple connection state link detection with Heartbeat