• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Threaded Socket.readObject() problem

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic