Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9186653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:34:56+00:00 2026-06-17T19:34:56+00:00

I’m getting a streamCorruptedException in the client when I try to get an object

  • 0

I’m getting a streamCorruptedException in the client when I try to get an object from a server.

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.
EDITED :

The following is my SERVER 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)
    {
    }

and following is client 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());
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:34:58+00:00Added an answer on June 17, 2026 at 7:34 pm

    You shouldn’t mix text and binary streams as this often leads to confusion unless you really know what you are doing.

    I suggest you wrap mainSock.getInputStream() and mainSocket.getOutputStream() once for the life of the stream and only use that. i.e. don’t call it more than once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.