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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:10:08+00:00 2026-05-31T16:10:08+00:00

I am trying to send objects over sockets in android emulators. Each emulator sends

  • 0

I am trying to send objects over sockets in android emulators.
Each emulator sends objects to itself and two other emulators.
The listening and sending of the objects are in two different ports and threads.
I get the java.io.StreamCorruptedException after it has sent the first packet.
In some cases the objects sent to the other emulators do reach ,but the object sent to itself never reaches itself after the first object is sent.
I have checked my object sending and receiving code with others, and they have told they see no issues, but i do get the exception consistently.
This post is as a last resort. Please help!

This is my server thread, which keeps listening –

public void StartListening() {
    new Thread(){
        public void run(){
            //packet p = null;
            try {
                ListenSocket =  new ServerSocket(L_PORT_NUM);
                packet p= null;
                Log.i("init","entering the listen while loop");
                while(true){
                    Socket TempSocket1 = ListenSocket.accept();
                    ois = new ObjectInputStream(TempSocket1.getInputStream());
                    p = (packet) ois.readObject();
                    decide(p);
                    ois.close();
                    TempSocket1.close();
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
    }.start();
}

decide() method spawns a new thread. Therefore no delay is incurred when the above method is called.

This is in the same program but completely different thread

    public void myWriteObject(packet m) throws IOException{
    final packet temp = m;
    //Create a new thread,Since network operations is not advised in main thread.
    new Thread(){
        public void run() {
            Log.i("myWriteObject","--------- ");

            int i=NUM_SYS;
            int temp_portNum=11108;

            while(i!=0){
                try {
                    Socket SendSocket1= new Socket("10.0.2.2",temp_portNum);
                    oos = new ObjectOutputStream(SendSocket1.getOutputStream());
                    oos.writeObject(temp);
                    oos.flush();
                    oos.close();
                    SendSocket1.close();

                    Log.i("myWriteObject","OBJECT SENT TO -"+temp_portNum);
                    i--;
                    temp_portNum=temp_portNum+4;
                    Thread.sleep(1000);

                } catch (UnknownHostException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }.start();

}

I keep getting java.io.StreamCorruptedException.
I have tried, closing, flushing and whatnots advised in gogle. But I still get this error.
Here is a snippet of the error log-
03-17 19:18:23.361: I/CLock(int n)(1638): clock initialized0 0 0
03-17 19:18:23.370: I/init(1638): entered oncreate
03-17 19:18:23.620: I/init(1638): entering the listen while loop
03-17 19:18:24.001: D/gralloc_goldfish(1638): Emulator without GPU emulation detected.
03-17 19:18:24.420: I/ActivityManager(100): Displayed project1.DistSys.App/.Project1Activity: +2s526ms
03-17 19:18:24.981: W/NetworkManagementSocketTagger(100): setKernelCountSet(10009, 0) failed with errno -2
03-17 19:18:33.961: I/TEST1(1638): sending to EVERYONE from TEST 1-1 0 0 5554:1
03-17 19:18:33.991: I/myWriteObject(1638): ---------
03-17 19:18:34.102: I/TEST1(1638): sending to EVERYONE from TEST 1-2 0 0 5554:2
03-17 19:18:34.120: I/myWriteObject(1638): ---------
03-17 19:18:34.500: I/myWriteObject(1638): OBJECT SENT TO -11108
03-17 19:18:34.500: I/INCOMING(1638): msg value 5554:0SEQUENCER MSG value 0seq_no value 0get key stamp 5554:0clock 1 0 0
03-17 19:18:34.520: W/System.err(1638): java.io.StreamCorruptedException
03-17 19:18:34.530: I/DECIDE(1638): packets seq_no value is-0 5554:0 5554:0
03-17 19:18:34.550: W/System.err(1638): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1528)
03-17 19:18:34.580: W/System.err(1638): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1481)
03-17 19:18:34.580: W/System.err(1638): at project1.DistSys.App.Project1Activity$9.run(Project1Activity.java:285)
03-17 19:18:34.600: I/DECIDE-CLKSTATUS(1638): INSERT TO DB port-clock-5554 2 0 0
03-17 19:18:34.820: W/System.err(1638): java.io.EOFException
03-17 19:18:34.840: W/System.err(1638): at java.io.DataInputStream.readByte(DataInputStream.java:98)
03-17 19:18:34.850: W/System.err(1638): at java.io.ObjectInputStream.nextTC(ObjectInputStream.java:506)
03-17 19:18:34.850: W/System.err(1638): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:778)
03-17 19:18:34.850: W/System.err(1638): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1999)
03-17 19:18:34.861: W/System.err(1638): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1956)
03-17 19:18:34.861: W/System.err(1638): at java.io.ObjectInputStream.readFieldValues(ObjectInputStream.java:1137)
03-17 19:18:34.880: W/System.err(1638): at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:455)
03-17 19:18:34.890: W/System.err(1638): at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1369)
03-17 19:18:34.977: W/System.err(1638): at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
03-17 19:18:34.977: W/System.err(1638): at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1851)
03-17 19:18:34.977: W/System.err(1638): at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
03-17 19:18:34.991: W/System.err(1638): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1999)
03-17 19:18:34.991: W/System.err(1638): at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1956)
03-17 19:18:35.011: W/System.err(1638): at

  • 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-31T16:10:09+00:00Added an answer on May 31, 2026 at 4:10 pm

    Solved the problem-
    I had declared objectinputstream and objectoutputstream as private and had made it global. This somehow corrupted the stream.
    By making both of them local , the error was eliminated.

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

Sidebar

Related Questions

I'm trying to sends XML serializable objects over a network stream. I've already used
I'm trying to serialize objects to send over network through a socket using only
I'm trying to send objects from bundles over a dedicated communication bundle to an
I am trying to send an anonymous object over a web service. Is there
I'm using asp.net mvc2 and trying to send a list of json objects with
I'm stumped on this. I'm trying to send an AJAX call by iterating over
I am trying to send an object in java over a physical network (not
I am trying to use JQuery to send a JavaScript Array object over Ajax.
I'm trying to send a QMouseEvent to the QML objects being currently displayed. The
got another issue. Im trying to send an entire Map of objects and their

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.