getting streamcurrupted exception in writing object second time
<p>I'm getting a <code>streamCorruptedException</code> in the client when I try to get an object from a server.</p>

<p>At first when the client connects to the server it works well, but when I try to connect a second client or when it runs a second time, the error occurs. I also tried to reset the stream on server end but it hasn't worked.
<strong>EDITED :</strong></p>

<p>The following is my <strong>SERVER</strong> code:</p>

<pre><code>       Socket clientSocket=null;
            BufferedReader rdr=null;
            ObjectOutputStream objwriter=null;
            String name="";
            audioReceiver = new TAudioReceiver(ser);
            videoReceiver = new TVideoReceiver(ser);
            fileReceiver = new TFileReceiver(ser);
            //audioReceiver.start();
            //videoReceiver.start();
            //fileReceiver.start();
            InputStream cliIn=null;
            OutputStream cliOut = null;
            ClientDetails client=null;


            while(true)
            {
                objwriter=null;
                clientSocket = ser.MainSocket().accept();
                cliIn = clientSocket.getInputStream();
                cliOut = clientSocket.getOutputStream();
                client = new ClientDetails(clientSocket);
                rdr= new BufferedReader( new InputStreamReader(cliIn));
                name = rdr.readLine();
                System.out.println("Client connected '"+ name +"'");

                boolean a = ser.clientsMainSockets.AddClient(name, client);
                if(a){
                    ser.clientsNames = ser.clientsMainSockets.ClientNames();

                    wr = new BufferedWriter(new OutputStreamWriter(cliOut));
                    wr.write("OKM");
                    wr.write('\n');
                    wr.flush();
                    objwriter = new ObjectOutputStream(cliOut);
                    //Thread.sleep(1000);
                    objwriter.writeObject(ser.clientsNames);
                    objwriter.flush();
                    clientSocket =null;
                    cliIn = null;
                    cliOut = null;

                    client = ser.clientsMainSockets.Value(name);

                    TMessageHandler msghdl = new TMessageHandler(ser, client.InputStream() , client.OutputStream(), name);
                    clientHandler.add(msghdl);
                    msghdl.start();
                    System.out.println("Starting process for client");
                    objwriter.reset();
                    Thread.sleep(5000);
                }
                else{

                        wr = new BufferedWriter(new OutputStreamWriter(cliOut));
                        wr.write("ERROR");
                        wr.write('\n');
                        wr.flush();
                }


            }
    }
    catch(Exception ex)
    {
    }
</code></pre>

<p>and following is <strong>client</strong> code :</p>

<pre><code> mainSock = new Socket(serverIp,serMainPort);
            serOut = mainSock.getOutputStream();
            serIn = mainSock.getInputStream();
            buffWr= new BufferedWriter(new OutputStreamWriter(serOut));
            //serOut = mainSock.getOutputStream();
            //serIn = mainSock.getInputStream();
            buffWr.write(myName);
            buffWr.write('\n');
            buffWr.flush();
            buffRdr = new BufferedReader(new InputStreamReader(serIn));
            String per="";
            per = buffRdr.readLine();
            System.out.println(per);
            if(per.equals("OKM"))
            {

                objin = new ObjectInputStream(serIn);
                ClientsName = (String[])objin.readObject();
                System.out.println("Client no.'"+ ClientsName.length );
                msgHandler = new TMainHandler(this, serOut, serIn);
                msgHandler.start();
            }
            else {
                throw new Exception("User Already exisits. Choose Another name.");
            }
        }
        catch(Exception ex)
        {
            throw new Exception(ex.getMessage());
        }
</code></pre>
