summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDor Bivas <dor1_b@walla.com>2013-12-20 21:27:37 +0200
committerDor Bivas <dor1_b@walla.com>2013-12-20 21:27:37 +0200
commit53d13d1f94b03edbf308c50426a9c465a79f8789 (patch)
tree71599b22db12d28c20a8dbdf011eada4b22647c6
parent3adfc654cffbbac6a36c26d818602d402c128377 (diff)
Server: a single connection shutdown function
-rw-r--r--src/Server/Connection.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Server/Connection.java b/src/Server/Connection.java
index 94853e1..676a65a 100644
--- a/src/Server/Connection.java
+++ b/src/Server/Connection.java
@@ -47,6 +47,15 @@ public class Connection extends Thread
this.soc = soc;
}
+
+ private void shutdown()
+ {
+ try
+ {
+ if (!soc.isClosed())
+ soc.close();
+ } catch (IOException e) {}
+ }
@SuppressWarnings("deprecation")
public void run()
@@ -76,7 +85,7 @@ public class Connection extends Thread
if (line == null)
{
System.err.println("Got null line");
- soc.close();
+ shutdown();
break;
}
parsedLine = new ParsedLine(line);
@@ -90,15 +99,8 @@ public class Connection extends Thread
}
} catch (IOException e)
{
- if (soc != null)
- try
- {
- soc.close();
- } catch (IOException e1)
- {
- e1.printStackTrace();
- }
e.printStackTrace();
+ shutdown();
}
}
}