Handling problems with receiving packages when you send files to Android classic Bluetooth

Source: Internet
Author: User

Requirement: Android Classic Bluetooth send file, send side support pause operation (Pervert!!!!!) ), also want to continue the breakpoint (more abnormal!!!) )

Approximate implementation:

Client sends a fixed length package, the first packet header (fixed length) contains this file identifier (name, total file flow length, etc.), and to handle the socket buffer

Overflow problem to prevent drops from appearing.

Server side read data from the socket in accordance with the fixed-length packet read, length is not enough, such as the next group of data, the length of the truncated, each data stream Baotou judgment, the previous file is not received, the case, received the packet header data stream, discarded, began to accept the new file stream.

Case point: The process of judging Baotou: There are two ways:

1. Fixed length package, each package contains a fixed length Baotou (flow waste)

2. Only the first Baotou, the header contains the file MD5 value (the file stream contains its MD5, there is only theoretically possible)

Handling problems with receiving packages when you send files to Android classic Bluetooth

Related Article

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.