Xerath
Xerath

Reputation: 1099

client/server, exception: StreamCorruptedException: invalid stream header: 75720002

In the following program, client has to enter numbers and send them to server. Server has to compute the numbers which client is sent and send that result to client.

For the following code, I'm getting exception inside my server class:

java.io.StreamCorruptedException: invalid stream header: 75720002
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804)

And inside my Client class, exception:

Exception in thread "main" java.util.NoSuchElementException: No line found
    at java.util.Scanner.nextLine(Scanner.java:1585)

How can I solve this problem ?

Upvotes: 1

Views: 965

Answers (1)

jtahlborn
jtahlborn

Reputation: 53694

You can't wrap multiple streams/writers around the same underlying stream (your client is wrapping the socket output stream twice and your server is wrapping the socket input stream twice). if you want to send Objects, you need to just use the Object based streams.

Upvotes: 3

Related Questions