A problem with java Object Streams via sockets -


I want to send double objects as objects in the form of an object OutputStream that socket for the output stream uses it. In the receiving party, I read repetitive objects. It may be that the read process does not execute the assignment of the object. I am trying to update dobArray and write in the socket output stream. DobArray has been updated by another thread This work is good because I tested it. Here is my code:

Sending to:

objectStream = New ObjectOutputStream (dataflow.accountputstream ()); While (busy) {try {// dobArray has been updated to another object objectStream.writeObject (dobArray); } Hold (IOException e) {e.printStackTrace (); }}

Received party:

  objectInputStream = New ObjectInputStream (mainServer.dataFlow.getInputStream ()); While (busy) {try {DobArray dobarray = (DobArray) Object InputStream.readObject () writeToFile (dobarray); } Hold (IOException e) {e.printStackTrace (); } Grip (Klassnotfound Expression E) {e.printStackTrace (); }} 

In relation to Sajid, the object overputstream is buffered. If you do not flush () flush it can wait, buffed indefinitely.

When you pass the reference of an object, then the value of that object passes only once. After that it only passes the object tag, it is continuously continuously being serialized without recurring objects. However, if you pass a temporary object, then the first copy is sent on.

The only way around this is to reset () the call, but the simplest solution is to use writeUnshared () which sends the object every time.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -