Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Sockets objectStreamReader  RSS feed

 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • 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
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks for your reply!

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

// Mathias
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!