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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:35:49+00:00 2026-05-26T22:35:49+00:00

Greetings and salutations, I have two Android apps: one is the server and one

  • 0

Greetings and salutations,

I have two Android apps: one is the server and one is the client. The server receives strings from two or more clients. The server tests collision of input (eg inputs received within 1 ms or whatever). Once a client establishes a connection with the server, the server instantiates a client object that runs a while-true thread which facilitates input reception.

I believe that with OS time-sharing of the CPU, threads alternate their execution. This is a problem since I need to know if two InputStreams send messages within a ms or two of each other. How may I allow this?


public void run() {
  while (true) {
    try {
      if (input.ready()) {
      String s = input.readLine();
          //do stuff, like comparing socket inputs
      }
    } catch (Exception e) {
  }
}
  • 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-26T22:35:50+00:00Added an answer on May 26, 2026 at 10:35 pm

    I think that you will find the bigger problem is that the network layer alone will introduce variability in timing in the order of many milliseconds (just look at the range of times when running ping), such that even if the clients all send at the exact same moment you will find that they will often all arrive at times with a delta larger than a few milliseconds. You will also likely run into other timing issues related to the handling of incoming network data depending on the radio hardware, and kernel configuration that sit between the VM and the physical network, on both the sender and receiver. My point is that detecting collision with the timing of a few ms is probably not possible.

    I’d suggest you send a timestamp with the message from the client so that it doesn’t matter when it processes. To make it even more accurate you can add some simple time synchronization to the startup of your protocol to find the delta between the client and server device clocks.

    If the goal is to just know which client sent data first, then you can just assume the blocked input.readline() that returns first is the one that sent data first, given data of similar length and similar ping latency for each client. This will under normal conditions be correct. To deal with variable length data and a number of other issues related to the physical network a good tweak would be to do a byte read rather than a whole line, which gives you a better approximation of who arrived first as opposed to which client is able to send the whole line faster.

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

Sidebar

Related Questions

I have pattern like below hi hello hallo greetings salutations no more hello for
File1: hello - dictionary definitions: hi hello hallo greetings salutations no more hello for
Greeting and Salutations! I work in an environment where I have a development server,
Greetings, I'm trying to find a way to 'unbind' a socket from a particular
Greetings! I am trying to check directory write-permissions from within a Windows MFC/ATL program
Greetings all, I'm looking for a more efficient way to grab multiple users without
Greetings, I have an asp.net mvc application. I have some links that corresponds to
Greetings, in my asp.net mvc application I have a listbox rendered as follows: <%=
Greetings, Any input on a way to divide a std::vector into two equal parts
greetings all i have a domain class named car and i have an object

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.