0

My server is in python and I'm trying to read and write to socket using ObjectInput/Output Streams whenever i write to socket there is some characters written in socket before my writeObject() command is executed and whenever i tried to read the data from socket using readObject() , it gives java.io.StreamCorruptedException: invalid stream header: 756C3A3A error. What is the problem? i've shown the screen shots of the added characters.

Attachments error.JPG 78.59 KB
3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by dantinkakkar
0

Java writeObject writes objects in its own format that can be decoded by readObject. It includes headers that describe the content that will follow. You're not going to have much success reading an ObjectOutputStream with anything other than an ObjectInputStream. Conversely you're not going to have much success writing data for an ObjectInputStream other than with an ObjectOutputStream.
If you want to share data between Java and Python you'll need to fall back to a simpler method (eg DataInput/OutputStreams) and invent your own protocol for how you send/receive objects.

0

OK thanx. But isn't there any way to share data between java and python using Object input and output streams?

0

OK thanx. But isn't there any way to share data between java and python using Object input and output streams?

You can't share a Java object with a Python file, because it won't be able to decipher it. You may want to look inside the readObject() code and try implementing it in Python.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.