• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

socket read-write-read-write-...

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
I am trying to create a server and a client using socket and serversocket. I'm spawning a new thread on serversocket.accept(), no problem there. My problem is as follows:
Each communiction from the server and a client is an object, currently sent using objectin/outputstreams.
I have no problems doing one iteration of client-write, server-read, server write, client-read.
but i don't know how many things the client will send to a server.
the client could send a request, wait for a response, send another request, get another response, etc.
I have a while loop, dong readObject/writeObject.
The readObject() doesn't seem to be blocking when reading from the socket on client/server side. So while the client is processing whatever the server sent, i get null reads on the server. Is there any way for me to block on the server/client on the readObject() until the other side sends something?

Thank you.
 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
readObject() does block the while loop !
 
Ed Green
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct!
The client was rudely disconnecting and i was mishandling an exception.

thank you
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic