aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes is DataOutputStream synchronized or not? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "is DataOutputStream synchronized or not?" Watch "is DataOutputStream synchronized or not?" New topic
Author

is DataOutputStream synchronized or not?

Daniil Sosonkin
Ranch Hand

Joined: Jan 15, 2004
Posts: 76
Hello,

I'm wondering whether DataOutputStream is synchronizing all its writes. In my scenario I have a thread which sends out streaming data on DataOutputStream and then another thread which sends out a small ping to the client every minute or so. Should I synchronize my message output function?

Thanx
sander hautvast
Ranch Hand

Joined: Oct 18, 2002
Posts: 71
java api doc says no synchronisation
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
Originally posted by Daniil Sosonkin:
Hello,

I'm wondering whether DataOutputStream is synchronizing all its writes. In my scenario I have a thread which sends out streaming data on DataOutputStream and then another thread which sends out a small ping to the client every minute or so. Should I synchronize my message output function?

Thanx


If one of these activities is streamed data, you will need to interrupt the stream to send your ping, which I assume is a keepalive. You should probably have the partner send a response every so often saying that they have received data and only send the keepalive if this response doesn't come within a particular time. If the ping isn't a keepalive, but serves some other purpose, you should use a second connection.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: is DataOutputStream synchronized or not?
 
Similar Threads
Servlet communication
sending an integer to a client machine
Thread not opening connections properly.
what's with the ThreadDeath
Comunication with a device through a socket