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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:06:02+00:00 2026-05-13T11:06:02+00:00

I use a Java Socket object in my client application. I need to know

  • 0

I use a Java Socket object in my client application. I need to know when the line to the server is broken, or if any event caused the socket to be dead.

I see two methods:

  • catching SocketException when writing in or reading from the socket, considering these exceptions kill the socket
  • when catching these exceptions, checking the Socket.isClosed() method to know if it killed the socket

Does any of these methods guarantee I’ll know when the socket is dead and won’t work again, even if a temporary problem on the line is solved?
Can we except a (Socket)Exception thrown during an operation on a socket to imply the socket is dead?

Is there a better method to know this?

  • 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-13T11:06:02+00:00Added an answer on May 13, 2026 at 11:06 am

    At least:

    1. Receiving an exception does NOT mean the socket is always dead, from Socket.setSoTimeout() javadoc:

      If the timeout expires [on a read for instance, a java.net.SocketTimeoutException is raised, though the Socket is still valid.

    2. The closed flag of the socket seems to be set only when the Socket.close() method is called, so I would not rely on it.

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

Sidebar

Ask A Question

Stats

  • Questions 536k
  • Answers 536k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If all you need is to add file version resource… May 17, 2026 at 1:26 am
  • Editorial Team
    Editorial Team added an answer Ok tried this, and realized that it doesn't work. The… May 17, 2026 at 1:26 am
  • Editorial Team
    Editorial Team added an answer You can do a permanant redirection from example.com/test/ to test.example.com.… May 17, 2026 at 1:26 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I know that the Java can use the Socket Programming to send an Object.
I use java ServerSocket class for server application. Does accept() method participate in tcp/ip
hello i have a basic client-server system running using java sockets. my problem is,
I'm trying to build a Java NIO-based socket server using Apache Mina. I really
I'm getting following error when my client tries to connect to my server socket:
I'm writing a Java application that will instantiate objects of a class to represent
Im implementing my own proto in Java, it will use a heartbeat over a
I need to communicate between a Java app (desktop) and an iOS app. I've
I have written an application that connects to a SSL web service (including client
I've become more and more comfortable programming in Java than with C++ or C.

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.