Select-based TCP server disconnection Processing

Source: Internet
Author: User

The camera and the mobile phone use a Transit server to forward data. If either party unexpectedly exits, the Select function execution will be abnormal.

You do not need to regularly check each socket descriptor on the server. The solution is as follows:

1) a heartbeat packet is sent every 30 seconds during video playback on the mobile phone and forwarded to camera by the server. If the heartbeat packet is not received for more than 30 seconds, camera interrupts the transmission and notifies the server to release the mobile socket descriptor.

2) when the camera is disconnected, the SELECT command gets a change in the fd_set of the camera, but the Recv returns an error. In this case, the server releases the socket descriptor of Camara directly.

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: 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.