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 7165113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:11:14+00:00 2026-05-28T14:11:14+00:00

I am sending data from one device to another (Samsung Tab and Sony Xperia).

  • 0

I am sending data from one device to another (Samsung Tab and Sony Xperia).
All is ok until I reach a length of 994 bytes.
At that point it splits it into 2 messages of 990 and 4 bytes. So, of course, the de-serialization fails.
I’m not sure if the splitting is at the sender end or the receiver end.

Why is that?
Is there a maximum it can send in one go?

If so, how can I piece it together?
If I knew that 990 was a fixed number then I could do it easily by combining them but does it vary from device to device?

I am giving it a buffer of 2000 bytes to receive into so there should be plenty of room.

I am using the code from the Bluetooth example.

======================================================================

As per TJD below:

At the moment I send an object like this:

public class BTMessage implements Serializable {

/**
 * 
 */
private static final long serialVersionUID = -2037775782014806765L;
public int what;
public Object objectToSend;
public int playerId;
public int currentPlayerId;
public BTMessage(int what, int playerId, int currentPlayerId, Object objectToSend){
    this.what = what;
    this.playerId = playerId;
    this.currentPlayerId = playerId;
    this.objectToSend = objectToSend;
}

objectToSend is a serialiazble object.

I then serialize it to a byte array and send it.

BTMessage btMessage = new BTMessage(what,playerId,currentPlayerId,objectToWrite);
write(toByteArray(btMessage));

At the other end I reverse the procedure.

Problem is that adding the length would not always help since, when deserializing the received message it will also want to deserialize the “objectToSend”. Since the message is incomplete I still end up with the same problem.

The only thing I can think of is to change it to:

public class BTMessage implements Serializable {
/**
 * 
 */
private static final long serialVersionUID = -2037775782014806765L;
    public int len;
public int what;
public byte[] objectToSend;
public int playerId;
public int currentPlayerId;
public BTMessage(int len, int what, int playerId, int currentPlayerId, byte[] objectToSend){
            this.len = len;
    this.what = what;
    this.playerId = playerId;
    this.currentPlayerId = playerId;
    this.objectToSend = objectToSend;
}

Then I would do the serialization in 2 steps. First I would serialize the object I want to send into the byte array. Then I would instantiate the “BTMessage” passing the byte array created from the serialization as “objectToSend” and serialize then that.
The above would now be:

byte[] message = toByteArray(objectToWrite);
BTMessage btMessage = new BTMessage(message.length,what,playerId,currentPlayerId,message);
write(toByteArray(btMessage));

At the other end, I would deserialize the received message. I would then check the length and perform another read until I have the full length.
Only then would I deserialize the full object sent (objectToSend).

Is this the way to go?

  • 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-05-28T14:11:15+00:00Added an answer on May 28, 2026 at 2:11 pm

    Are you using RFCOMM to send the data? If so, then you can’t rely on any assumptions about packet size. The RFCOMM abstraction is similar to a serial port, where you are just sending streams of bytes. There is no concept of packets in the RFCOMM data.

    You may find that naturally small packets usually get lumped together, but the segmentation size over the air will always vary depending on internal parameters specific to each bluetooth chip. There is no setting for you to control that would reliably preserve your expected packet size.

    You should do what you would do for serial port data, overlay your own packet headers in the data so the other side can reassemble. This could be as simple as sending an extra two byte length value before the rest of each data packet. Then the receiver gets a data stream that is self-describing.

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

Sidebar

Related Questions

I'd interested in sending data from one WP7 to another WP7 phone so I
Im sending data from one class to another, Its working but I have a
I'm sending data from one page to the next in an MVC2 app. Page
I'm sending a very large string from one application to another on localhost using
I am receiving data from a device that's sending information over the serial port
I'm sending sensor data from an android device to a TCP server in C#.
I have a MySQL query that is copying data from one table to another
I am trying to transfer data from one page to another but some problem
I have a program whereby Data is being sent from one computer to another
Hi I have a problem in sending data from php to pdf. I think

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.