Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7759909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:44:45+00:00 2026-06-01T13:44:45+00:00

I am currently developing my program using sample BluetoothChat program on android device. This

  • 0

I am currently developing my program using sample BluetoothChat program on android device. This is the website that you can refer to: http://developer.android.com/resources/samples/BluetoothChat/src/com/example/android/BluetoothChat/index.html

Base on some reasons, I want to continue sending the message to the receiver. Hence, I do this on a method called sendMessage() in BluetoothChat class.

byte[] send = message.getBytes(); 
for(int i = 0; i < 5; i++)  //simply add a while loop here
mChatService.write(send);

Sometimes, the messages will jam to each other. e.g. the message is 1234. So the receiver should receive five indivual messages. However, the receiver may receive 4 message and one message is 12341234. The pattern is not unique. Sometimes the receiver 3 message with two message is 12341234. Sometimes it runs perfectly which receive five indivual messages.

I don’t know which one(sender or receiver or both) having the problem. How to fix such problem? Thx a lot~

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:44:46+00:00Added an answer on June 1, 2026 at 1:44 pm

    It appears that you are assuming a one-one correspondence between write and reads. Often it does work that way, but there is no guarantee – the odd behavior that you are seeing is actually typical.

    As a result, you are responsible for breaking the data that you receive (via your socket.read) into messages.

    Typically you would use messages of a fixed length or you would include the length of the message in the message header. Using fixed length messages really simplifies things, but is usually not flexible enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently developing a program that uses C#'s Dictionary container (specifically, SortedDictionary). This
I'm currently developing a percussion tutorial program. The program requires that I can determine
I am currently developing an android program. After some searching i can't seem to
Currently developing an application using the newest version of symfony, obtained through PEAR. This
I'm currently developing a widget that can be embedded within a page. However, when
I'm developing a program using Windows 7. There are WCF services (soap, rest) that
Currently am developing a program that solves (if possible) any given labyrinth of dimensions
I am developing a C# app that can NOT connect to the internet. This
Using ASP.Net Am New to website development Currently am developing a web pages, when
I am developing a Java program using Eclipse that should exit with different codes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.