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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:38:08+00:00 2026-05-31T12:38:08+00:00

Here is the situation. I’m creating an Android that utilises Bluetooth to update connected

  • 0

Here is the situation. I’m creating an Android that utilises Bluetooth to update connected clients of each other’s status. The idea is for the host of the Bluetooth connection to hold a multi-dimensional array holding all of these stats. Each time a client updates the host of their new status, the host then update the data in the array and then sends this to all the clients.

Of course, this all sounds like milk and cookies to me, but unfortunately it is not. I understand that I need to have a Bluetooth socket on each end and one of them needs to be a host socket. So, get one connection done seems pretty straight forward. But what if I then want to accept more connections? I’ve been reading around and apparently I have to create a new thread for each connection. I don’t see how that would work, could someone please explain this?

  • 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-31T12:38:10+00:00Added an answer on May 31, 2026 at 12:38 pm

    The reason you need a thread for each connection is this:

    Imagine you have two opened sockets, sock1 and sock2. To read from those sockets, you might call something like

    InputStream in1 = sock1.getInputStream();
    InputStream in2 = sock2.getInputStream();
    

    Now, to read from sock1, you call

    in1.read(buffer);
    

    where “buffer” is a byte array, in which you store the bytes you read.

    However, read() is a blocking call – in other words, it doesn’t return, and you don’t get to execute the next line, until there are some bytes to read(). So if you try to read sock1, you’ll never get to read sock2, and vice versa, if they’re in the same thread.

    Thus if you have one thread per connection, each thread can call read(), and wait for input. If input comes while one of the other threads is executing, it waits until that thread’s turn comes up, and then proceeds.

    To actually implement this, all you need to do is stick the code to handle one connection into a class that extends Thread.

    There are lots of details involved – I would suggest the Android BluetoothChat sample as a good tutorial.

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

Sidebar

Related Questions

Here's the situation - I've got a shell that loads an external .swf. Now,
I have a very dramatic situation here. I need the android sdk and I'm
I'm having a bit of a weird situation here. I have a form that
My situation here is that I need to send my program to my university's
So here the situation. I have multiple strings that begin and end with a
I have a tricky CSS situation here. Basically I have nested span tags that
So, hypothetical situation here: I have an SWF that's 30MB. Sound files (music) make
Okay, here a situation: 1) I have a Panel called panel1 that consist one
Very odd situation here. For some reason I can't call 'Where', or any other
There is a situation here, I'm developing an Android application, using Java. I'm pretty

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.