• Post Reply Bookmark Topic Watch Topic
  • New Topic

Threaded Socket.readObject() problem  RSS feed

 
Andy Nimmo
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a problem with an application that i'm currently writing. I'm using Sockets to connect between a client and server. With a new Thread running for each client Socket connection.
The problem is that my "readObject( )" method is in a "while" loop as seems to be the standard way of doing things as object will arrive at this Socket at random intervals.
The snippet of code is as follows:

Without wanting to go into too much detail with regards to the code surrounding this try block the problem basically comes down to the fact that I'm ignoring IOExceptions and it all works except it takes a very long time to register that a new Object has arrived at the Socket.
Obviously this is because that Thread is tanking along within its loop but I was under the impression that a Socket operation such as this was blocking and as such would only continue when it was able to complete.
Can anyone suggest a better way of achieving the above result but without the long delays I'm experiencing? there is no other code in this "while" loop.
Any help appreciated!
Andy.
- I drink therefore I am
 
Andy Nimmo
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this needs to be moved to the Performance forum as it's a more performance related question!
Andy.
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will do Andy, definitely seems like you are looking for a better way, algorithmically, to deal with this issue. Good luck!
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm curious to see the transmit side of this equation. Do you call flush() on the ObjectOutputStream? What about setting setTcpNoDelay() on the socket to avoid TCP packet buffering?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!