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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:28:25+00:00 2026-05-26T23:28:25+00:00

As the topic suggests I have a server and some clients. The server accepts

  • 0

As the topic suggests I have a server and some clients.
The server accepts I/O connections concurrently (no queueing in socket connections) but I have this troubling issue and I do not know how to bypass it!
If I force a client to throw an I/O Exception the server detects it and terminates the client thread correctly (verified from Task Manager (Windows) and System Monitor (Ubuntu) ). But If I emulate an I/O that is “hanging” like
i.e.
Thread.sleep(60*1000);
or

private static Object lock = new Object();

synchronized(lock) {
   while (true) {
      try {
         lock.wait();
      } catch (InterruptedException e) {
         /* Foo */
      }
   }
} 

then all subsequent I/O operations (connection & data transfer) seem to block or wait until the “hanging” client is terminated. The applications makes use of the ExecutorService so if the “hanging” client does not complete the operations in the suggested time limit then the task will time out and the client is forced to exit. The subsequent “blocked” I/Os will resume but I wonder why the server doesn’t accept any I/O connections or performs any I/O operations when a client “hangs”?

NOTE:The client threading takes place in the server main like this:

while (true) { 
   accept client connection;
   submit client task;
          ||
         \  /
          \/ 
   // ExecutorService here in the form 
   // spService.submit(new Callable<Tuple<String[], BigDecimal[]>>() { 
   // ... code ... }}).get(taskTimeout, taskTimeUnit);
   check task result & perform cleanup if result is null;
   otherwise continue;
}
  • 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-26T23:28:26+00:00Added an answer on May 26, 2026 at 11:28 pm

    I think I have found the source of my problems!
    I do use one thread-per-client model but I run my tests locally i.e. in the same machine which means all of them have the same IP!
    So each client is assigned the same IP with the server! I guess that this leaves server and clients to differ only in port number but since each client is mapped to a different localport for each server connection then the server shouldn’t block. I have confirmed that each client and server use different I/Os (compared references) and I wrap their sockets using <Input/Output>Streams to BufferedReaders & PrintWriters but still when a client hangs all other clients hang too (so maybe the I/O channels are indeed the same???)!
    I will test this on another machine and check the results back with you! 🙂

    EDIT: Confirmed the erratic behaviour. It seems that even with remote clients if one hangs the other clients seem to hang too! :/
    Don’t know but I am determined to fix this. It’s just that it’s pretty weird since I am pretty sure I use one thread-per-client (I/Os differ, client sockets differ, IPs seem to be not a problem, I even map each client in the server to a localport of my choice …)
    May be I’ll switch to NIO if I don’t find a solution soon enough.

    SOLUTION: Solved the problem!
    It seemed that the ExecutorService had to be run in a seperate thread otherwise if an I/O in a client blocked, all I/Os would block!
    That’s strange given the fact that I’ve tried both an Executors.newFixedThreadPool(<nThreads>); and Executors.newCachedThreadPool(); and the client actions (aka I/Os) should take place in a new Thread for each client.
    In any case, I used a method and wrapped the calls so each client instace would use a final ExecutorService baseWorker = Executors.newSingleThreadExecutor(); and created a new Thread explicitly each time using <Thread instance>.start(); so each thread would run in the background 🙂

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

Sidebar

Related Questions

As the topic suggests I have some problems with PropertyInfo.SetValue. To get to the
This topic has been scratched once or twice, but I am still puzzled. And
This is slightly off topic of programming but still has to do with my
I read this topic, but his problem maybe different from mine Writing to both
I have been querying google for some material about kd-trees and image comparison but
I have tried multiple tutorials on this topic from Forta.com and yet run into
I hope this is not to off-topic for this site. Recently I have had
As the topic suggests I wish to be able to pass table names as
The topic generically says it all. Basically in a situation like this: boost::scoped_array<int> p(new
I have a java class Processor that is listening to a jms topic and

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.