StreamCorruptedException only on last Client
<p>currently I am writing a Client - Server Game.</p>

<p>For Testing Purpose I made a very small Console Client.</p>

<p>On the Server GUI I can choose how many Players are playing in this Round.</p>

<p>The first Message (LoginMessage) is no Problem and all Clients answer with a Response.</p>

<p>My Problem is, that if I start the Game (this causes my Server to Send a "GameStart" Message to all Clients) only the last connected Client gets a StreamCorruptedException.</p>

<p>I tried the Code on a Win8 Computer and it worked perfectly. Only on my Win7 (64Bit) computer it doesn't work. (I couldn't test it on any other Computer).</p>

<p>Here is the Code for from the Server:</p>

<pre><code>/**
 * Creates a new Socket
 * @return Returns the internal ID to access the Socket
 */
public int createNewSocket(){
    Socket newSocket;
    try {
        newSocket = welcomeSocket.accept();
        newSocket.setSoTimeout(1000);
    } catch (IOException e) {
        Debug.LogError(e.getMessage());
        return -1;
    }

    Clients.add(newSocket);
    InputStream is;
    OutputStream os;

    ObjectInputStream ois;
    ObjectOutputStream oos;

    try {
        is = newSocket.getInputStream();
        ois = new ObjectInputStream(is);

        os = newSocket.getOutputStream();
        oos = new ObjectOutputStream(os);
    } catch (Exception e) {
        Debug.LogError(e.getMessage());
        return -1;
    }  
    istreams.add(ois);
    ostreams.add(oos);
    return Clients.size() - 1;
}


public boolean sendMessage(int id, IMessage message) throws IOException{
    ObjectOutputStream out = ostreams.get(id);
    Debug.Log("ID: " + id + " | OOS" + out);
    if (out == null){
        return false;
    }

    out.writeObject(message);
    return true;
}
</code></pre>

<p>The createNewSocket() Function creates and Stores the necessary Streams (OIS and OOS)
I am sending the Messages with the sendMessage(...) Function.
My teammate develops a GUI Version from the Client and until now we didn't get any problems with these Functions.</p>

<p>The Code which produces the Error is the following (from the Test-Client):</p>

<pre><code>    try {
        Socket s = new Socket("localhost", 8080);
        OutputStream os = s.getOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(os);

        InputStream is = s.getInputStream();
        ObjectInputStream ois = new ObjectInputStream(is);


        LoginRequest to = new LoginRequest(name);
        oos.writeObject(to);

        while (true) {
            IMessage response = null;

            Debug.Log(""+ois);  // I just wanted to check if the ois is still the same

            IMessage mess = (IMessage)ois.readObject(); // I get the Error in this line
            Debug.Log("" + mess);
/* Now I'm doing some stuff with the Message.*/
</code></pre>

<p>I read that this Error often comes when a second Stream is created. But this is not the case here. And the same Codes works for all Clients except the last. 
(If I start with 3 Players, the 3 Player gets this error and so on).</p>

<p>I hope someone here has a possible Solution or even just a reason why this is happening.</p>

<p>EDIT:
Here is the full Stacktrace:</p>

<pre><code>java.io.StreamCorruptedException: invalid type code: 00
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.skipCustomData(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.skipCustomData(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at server.TestClient.main(TestClient.java:71)
</code></pre>

<p>Greetings,
M. Mauer</p>
