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.

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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.