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

  • Home
  • SEARCH
  • 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 6234171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:26:12+00:00 2026-05-24T10:26:12+00:00

the writer: socket.setSendBufferSize(1); socket.setTcpNoDelay(true); writer = new BufferedWriter( new OutputStreamWriter(socket.getOutputStream(), UTF-8)); is used as

  • 0

the writer:

   socket.setSendBufferSize(1);
   socket.setTcpNoDelay(true);
   writer = new BufferedWriter(
          new OutputStreamWriter(socket.getOutputStream(), "UTF-8"));

is used as follows:

try {
        writer.write(packet.toXML());
        writer.flush();
        ...
    }
    catch (Exception ioe){
        if (!done) {
            done = true;
            ... 
        }       
    }

This is client side code. When its server disconnects the socket (also java code), how come the client will only throw after 5 – 10 minutes ? Should it not throw at the first attempt to write over the dead connection ?

Thanks

Edit:

after shutting down the server, here are the TCP states:

tcp        0      0 server:443     client:50283   FIN_WAIT2 

tcp4       0      0  cient.50283     server.443       CLOSE_WAIT

Edit2:

client is an android application. Ran from phone, the second packet written causes a throw. Ran from an emulator (Mac underneath) the fourth write() will throw.

  • 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-24T10:26:13+00:00Added an answer on May 24, 2026 at 10:26 am

    Should it not throw at the first attempt to write over the dead
    connection ?

    No. All it knows is that a FIN has been received, which could have just been a shutdownOutput() by the peer – it could still be reading. So TCP has to send the data. If the peer has closed, it will issue an RST, which TCP will provide to the application on a subsequent write.

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

Sidebar

Related Questions

How does TCP/IP report errors when packet delivery fails permanently? All Socket.write() APIs I've
I'd like to write a basic socket chat app, except encrypted. Y'know all those
I am trying to write a sample Raw socket program to clear my understanding
How to write byte by byte to socket in PHP? For example how can
I am trying to write an application that uses java.net.Socket. I have also written
I am trying to write a simple program to open a socket channel to
I want to write a function that read line by line from a socket
Hi everbody i have to write a server which communicate over a socket connection.
What is getting written to the socket when I write an ENUM reference (below)?
I'm trying to write a client/server program with threads. I close the socket once

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.