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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:42:55+00:00 2026-06-08T00:42:55+00:00

I have multiple clients and one server. Server handles each client in one thread.

  • 0

I have multiple clients and one server. Server handles each client in one thread. Clients must send a custon object to the master. I checked this and this, which talk about the error java.io.StreamCorruptedException: invalid type code: AC which is exactly I’m having.

But I didn’t understood the proposed solution. He inherits the ObjectOutputStream and simple does not write the header in the second and following times the object must be sent. This is not working for me.

Is there another solution to send custom objects throught TCP sockets? My clients gather their data every 10 seconds and re-created the object which is sent.

I’m sorry if i’m being repetitive, I’m reading a lot of similar question but finding no answers to my scenario.

Thanks in advance

EDIT

Send method (in the client)

    public void TCPEchoClientSend(MonitoredData _mData) throws IOException {
        if (_mData == null)
            throw new IllegalArgumentException("Parameter: <Monitored Data> empty.");           
        ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());

        // Send the encoded object to the server
        oos.writeObject(_mData);

        oos.close();

        System.out.println("Client sent the monitored data package.");

    }

Receive

public static void handleEchoClient(Socket client, Logger logger) {
        try {
            MonitoredData mdata;
            // Get the input and output I/O streams from socket
            ObjectInputStream ois = new ObjectInputStream(client
                    .getInputStream());
            ObjectOutputStream oos = new ObjectOutputStream(client
                    .getOutputStream());

            // Receive until client closes connection, indicated by -1;
            while ((mdata = (MonitoredData) ois.readObject()) != null) {

                System.out.println("Got received data. Ready to save.");

                hdb.saveOrUpdate(mdata);

                System.out.println("Monitored Data arrived at home.");

            }

            // logger.info("Client " + _clntSock.getRemoteSocketAddress()+
            // ", echoed " + totalBytesEchoed + " bytes.");

        } catch (IOException ex) {
            logger.log(Level.WARNING, "Exception in echo protocol", ex);
        } catch (ClassNotFoundException e) {
            logger.log(Level.WARNING, "Exception in echo protocol", e);
        } finally {
            try {
                client.close();
            } catch (IOException e) {
            }
        }
    }
  • 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-08T00:42:57+00:00Added an answer on June 8, 2026 at 12:42 am

    Use the same ObjectOutputStream and ObjectInputStream for the life of the socket, at both ends, and look up the ObjectOutputStream reset() and writeUnshared() methods.

    See this answer for a discussion.

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

Sidebar

Related Questions

How do you handle multiple client to connect to one server? I have this
Currently I have a database with the following relationships: One Client has multiple Entities
i am doing a project that will have multiple channels for clients chatting. Each
I have a server that connects to multiple clients using TCP/IP connections, using C
I have a remote server which handles various different commands, one of which is
I am creating a servlet(proxy server) which handles multiple request from the client.I do
We have a remoted singleton object hosted in IIS which is servicing multiple clients.
I have wrote a server program that can handle multiple client by using fork().
I have written C code for a TCP server to listen to one client
If I have multiple Oracle clients installed on a given workstation (i.e. Oracle 9

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.