I am creating a Java a simple client/server program although both are just working fine. The problem is that when the client or the server encountered an error it will stop. Is there a way for my client/server app to continuously run even if it encounters an error?
Asked
Active
Viewed 934 times
-1
-
3`try`/`catch` must help you :) – NiziL Feb 04 '15 at 13:37
-
Can you add some source code? Have you thought of running each in separate thread? – El Guapo Feb 04 '15 at 13:37
-
I haven't tried threads yet any sample code you can give? – dimas Feb 04 '15 at 13:39
1 Answers
0
You should run your code in a loop and catch any exceptions inside your loop. e.g.
while (true) {
try {
//Do what ever your server does
} catch (Exception e) {
//Log your exception to a log file
}
}

bhspencer
- 13,086
- 5
- 35
- 44