dcsimg
How do you retrieve the error code (not msg) of a failed socket read?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jeff_Lynn
Posted On:   Friday, July 16, 2004 12:07 PM

How do I determine if the failed receive using BufferedReader is a "read timeout" or other error such as "connection closed?".

Using SocketException, I can retrieve the error message to tell me the cause, but I was unable to obtain an error code so I can programmically recover the error.

Should I use isConnected(), isClosed() to tell the different?

Thanks!

jml

Re: How do you retrieve the error code (not msg) of a failed socket read?

Posted By:   Simon_Ablett  
Posted On:   Monday, July 19, 2004 06:01 AM

Java only provides a high-level interface to the socket layer. I am afraid that you are stuck with calls to 'isConnected' etc if you need for data.

Regards

Re: How do you retrieve the error code (not msg) of a failed socket read?

Posted By:   Jeff_Lynn  
Posted On:   Friday, July 16, 2004 01:37 PM

A blocked read yields a null string on the BufferedReader.readline() method so I can tell from there that the read timed-out.

However, any other socket error or aborted connection yield an IOException with an explicit error message but sure you don't want to parse an error message to determine what cause the socket error!

In C++ socket call, there are explicit method to determine the numeric value of the error. So any hint on the Java socket API is wellcome!

Thanks!

jml
About | Sitemap | Contact