• 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

Sockets objectStreamReader

 
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, just wondering!

I use sockets from server to applet and it works fine. When I use writeObject and readObject over streams does the application wait for the object to write and read or how does it all work.

Ex.

Applet connects to server.
Server responds and puts the socket in a new thread
I use readObject and recieves data from the applet
Server responds by writing information to applet via objectStream
Applet recieves the data

This works. How long does the applet, server waits for the streams? How do I know if the whole object is sent?

// Mathias
 
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

Originally posted by Mathias Nilsson:
When I use writeObject and readObject over streams does the application wait for the object to write



readObject() blocks until it receives an object. Of course, using it over a network connection you can have a timeout or interruption so you should be prepared to handle that. The JavaDoc for ObjectInputStream and ObjectOutputStream as well as the Java Tutorial chapter on Serialization are essential for understanding what happens when an object is serialized and de-serialized.
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply!

Maybe the best approach is to do all the Socket communication in a Thread?

// Mathias
 
Everybody's invited. Even this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic