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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:15:13+00:00 2026-06-02T17:15:13+00:00

Here is what I have right now. Receiver: public static void read(Socket socket, ObjectInputStream

  • 0

Here is what I have right now.

Receiver:

public static void read(Socket socket, ObjectInputStream in) {
    try {
        String separator = in.readUTF();
        while (in.readByte() == -3) {
            String path = in.readUTF().replaceAll(separator, System.getProperty("file.separator"));
            File file = new File(new File(path).getParent());
            if (!file.exists()) {
                file.mkdirs();
            }
            FileOutputStream fos = new FileOutputStream(path);
            int b = 0;
            while ((b = in.readByte()) != -4) {
                fos.write(b);
            }
            fos.close();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Sender:

public static void send(String[] path) {
    Socket socket;
    try {
        socket = new Socket(ip, port);
        socket.setKeepAlive(true);
    } catch (UnknownHostException e) {
        return;
    } catch (IOException e) {
        return;
    }
    try {
        ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
        out.writeUTF(Devbox.getSeparator());
        for (String s : path) {
            send(s, out);
            out.writeByte(-2);
        }
        out.close();
        socket.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

private static void send(String path, ObjectOutputStream out) {
    File file = new File(path);
    if (file.isDirectory()) {
        File[] files = file.listFiles();
        for (File f : files) {
            send(path + f.getName(), out);
        }
    } else {
        try {
            out.writeByte(-3);
            out.writeUTF(path);
            FileInputStream fis = new FileInputStream(file);
            int b = 0;
            while ((b = fis.read()) != -1) {
                out.writeByte(b);
            }
            fis.close();
            out.writeByte(-4);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

This is the error I get in the sender.

java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    at java.io.ObjectOutputStream$BlockDataOutputStream.writeBlockHeader(ObjectOutputStream.java:1874)
    at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1855)
    at java.io.ObjectOutputStream$BlockDataOutputStream.writeByte(ObjectOutputStream.java:1895)
    at java.io.ObjectOutputStream.writeByte(ObjectOutputStream.java:760)

It points to

                out.writeByte(b);

It sends about 25 files successfully, then throws this error. The file it throws it on is different each time, but it is in the same range of about 5 files. The receiver stops after one specific file which is usually a couple before the file the sender stops on. It stops because in.readByte() == -3 is false. When it happens, I got numbers like -85 and 16. I tried it on another computer, since it said something about software, and it was the exact same. Does anyone know why this is happening? I’ve spent a day trying to figure it out, and gotten nowhere. Any help is greatly appreciated.

  • 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-02T17:15:14+00:00Added an answer on June 2, 2026 at 5:15 pm

    Please read this answer, I don’t think anything else can be said beyond that, also I don’t see anything in your code which will close the connection.

    From OTN Discussion

    WinSock description: The error can occur when the local network system
    aborts a connection. This would occur if WinSock aborts an established
    connection after data retransmission fails (receiver never
    acknowledges data sent on a datastream socket).

    TCP/IP scenario: A connection will timeout if the local system doesn’t
    receive an (ACK)nowledgement for data sent. It would also timeout if a
    (FIN)ish TCP packet is not ACK’d (and even if the FIN is ACK’d, it
    will eventually timeout if a FIN is not returned).

    It seems to happen more with WindowsXP and it seems also to be
    possibly related to Windows firewall settings. In any case the salient
    point is that the abort has originated inside the local machine.

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

Sidebar

Related Questions

I have a problem here. Right now I'm doing my Web Based Application, my
Here's my question. Right now I have a Linux server application (written using C++
Here is the thing. Right now I have this e-commerce web site where people
I have a problem with this code right here: - (void)fetchedData:(NSData *)responseData { //parse
i have this code right here: <select name=group> <option value=>Choose a group....</option> <?php foreach($groups
I have this form right here, where the user will add the start date
Hey I have this code right here: http://pastie.org/534470 And on line 109 I get
OK, I don't think the title says it right... but here goes: I have
I Have wrote a question which got a right answer here about emysql encoding.
I have a button as made for you to see here . Looks fine,right?

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.