Problem solving-Simple connection state link detection with Heartbeat

Source: Internet
Author: User

================================== 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

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.