Exception: Connection reset
Hi,
I use this code
import java.io.*;
import java.net.*;
...
publicvoid run(){
try{
ServerSocket ss =new ServerSocket(TCP_PORT);
while (true){
Socket sock = ss.accept();
in =new BufferedReader(
new InputStreamReader(
sock.getInputStream()));
out =new PrintWriter(
new BufferedWriter(
new OutputStreamWriter(
sock.getOutputStream())),true);
String msg = in.readLine();
}
}catch (Exception ex){
serverLog("while exception: " + ex.getMessage());
}
}
...
BufferedReader in;
PrintWriter out;
When this part of code will logwhile exception: Connection reset?
Thank you.
[1493 byte] By [
boba5555a] at [2007-11-26 16:03:54]

# 2
I am closing accepted sockets. I didn't post you whole code, only part which takes connection.> You mostly get this on writing, not reading.What can be cause? I got that message.
# 4
Does ex.toString() will write the whole message (the same as printStactTrace)? Then I should change code and wait for another error (I hope it will not happen again). It should work during the whole day at least for two months.
What is "usual" time after which some server (ie. java server) should be rebooted?
# 5
> Does ex.toString() will write the whole message
> (the same as printStactTrace)?
Nope, you should usually do both when you have a catch block. (There are some situations where an exception is expected and does not require operator intervention, so a trace may be skipped.)
If you only have the message, or the stack trace, post those, complete and unedited; maybe someone can figure something out from them. In particular, I'm looking for any hint to what operation caused the error: accept, read, write, select, ...
> What is "usual" time after which some server (ie. java server)
> should be rebooted?
If you have a properly written program, with no memory leaks and such, there should be no reason ever to restart the program or reboot the server. Only things like critical operating system patches or hardware upgrades should require a reboot.
# 8
I want, but I cann't get it again. I use some program which makes java file to be service, so I don't see what write in a console, only what I can log into file, because that I aksed what can be cause, some "global" cause.... If I get it again, I will send here the whole stackTrace, if ex.toString() will log the same as ex.printStackTrace()...