Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Socket Exceptions

Posted on 2004-08-25
7
Medium Priority
?
216 Views
Last Modified: 2010-03-31
Is it possible to have exception from an InputStream.read or an OutputStream.write using java.lang.Socket and the socket still be valid (readable/writable)?  What I am getting at is if an exception occurs during a socket read/write should I automatically consider the socket connection invalid?  Is there any documentation on this?

Thanks
0
Comment
Question by:nealgoodman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 11894709
No, it doesn't necessarily make the Socket invalid, though it depends on why it was caused. What are the specifics?
0
 
LVL 1

Author Comment

by:nealgoodman
ID: 11896873
I guess what I want is a checklist of items that cause a socket to become invalid.  I want to make sure that I am able to determine when the socket is no longer valid.  I know the only real way to do this is to get a write failure.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11896924
>>I know the only real way to do this is to get a write failure.

That's quite right, and probably the only real way to tell with accuracy
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 11898047
You should consider the socket invalid after you have recieved an exception.
Unless you have a specific reason to believe otherwise.
0
 
LVL 1

Author Comment

by:nealgoodman
ID: 11899168
>You should consider the socket invalid after you have recieved an exception.
>Unless you have a specific reason to believe otherwise.

Is there any documentation on this?  What would be a good "specific reason"? Currently I am doing exactly what you are saying in conjunction with a "ping" message we send every N seconds to make sure the socket is still alive.
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 11899230
> What would be a good "specific reason"?

If you are not aware of any then there probably aren't any :)
There's an unlimited number of different type of exceptions that could occur, so getting a definitive answer is probably not even possible.
When in doubt your safest assuming the connection is trashed, otherwise you could end up in an even bigger mess. And when you find any exceptions that don't trash it, then add special handling for that exception.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11901475
Hmm. Not quite sure why you accepted that as the only 'correct' answer. Perhaps you can illuminate ...?
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question