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 579849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:24:35+00:00 2026-05-13T14:24:35+00:00

I am building a client-server application. Now I want to forward the message from

  • 0

I am building a client-server application. Now I want to forward the message from a client to all other client with this code:

ArrayList<User> usrs = _usrHandler.getUsers();
for(User usr : usrs) {
    if(!usr.getSocket().equals(_connection)) {
        usr._oOut.writeObject(new CommunicationMessage(this._comMsg.getMessage(), CommunicationMessage.MSG, 
                                                    this._comMsg.getUser()));
 }
}

On the client side the program is listening for messages. It throws this exception:

java.io.StreamCorruptedException: invalid stream header: 7371007E
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:783)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)
    at Connection$MessageListener.run(Connection.java:126)
    at java.lang.Thread.run(Thread.java:637)

MessageListener:

             while(this._loop) {
 this._comMsg = (CommunicationMessage) this._dataInput.readObject();

 SimpleAttributeSet attr = new SimpleAttributeSet();
 attr.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE);
 attr.addAttribute(StyleConstants.CharacterConstants.Foreground, _comMsg.getUser().getColor());

 messageClient.addMessage(_comMsg.getUser().getNickName() + ": ", attr);
 messageClient.addMessage(_comMsg.getMessage(), _comMsg.getUser().getColor());

 _comMsg = null;
}

Does someone see the error?

  • 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-05-13T14:24:35+00:00Added an answer on May 13, 2026 at 2:24 pm

    You’ve likely got your streams in a twist.

    When you construct an ObjectInputStream, the constructor reads the first two bytes from the stream expecting them to be the “magic values” that should be present in an object stream. If they’re not there, it throws the StreamCorruptedException (this is all in the ObjectInputStream source code).

    So it would appear that you’re wrapper an InputStream in an ObjectInputStream when in fact the data coming down from the other end of the connection is not actually an object stream. Perhaps it’s still sending data from a previous communication.

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

Sidebar

Related Questions

I'm building client/server apllication on QT. I just want user to execute only one
I'm building an application in C, which is a client/server sharing app. This application
I'm building a client server application from an android device to a server over
i am building a server application using eclipse , and the client is android
I am building a client that can recieve information from the server and from
I'm building a client that talks to the http server. Now my client needs
I'm building a client-server application and I am looking at adding failover to the
I'm building a client-server (c#) application that uses a web services to synchronize the
I am building a client-server based solution; client being a desktop application and the
I'm building a non-browser client-server (XULRunner-CherryPy) application using HTTP for communication. The area I'm

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.