Skip to content
Snippets Groups Projects
Commit e774ef57 authored by Terry D. Norbraten's avatar Terry D. Norbraten
Browse files

close socket

parent 36321eb7
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ public class TcpExample3Client { ...@@ -22,7 +22,7 @@ public class TcpExample3Client {
public static void main(String[] args) { public static void main(String[] args) {
// Local variables/fields // Local variables/fields
Socket socket; Socket socket = null;
InputStream is; InputStream is;
InputStreamReader isr; InputStreamReader isr;
BufferedReader br; BufferedReader br;
...@@ -72,6 +72,11 @@ public class TcpExample3Client { ...@@ -72,6 +72,11 @@ public class TcpExample3Client {
} }
finally // occurs after any other activity when shutting down finally // occurs after any other activity when shutting down
{ {
try {
if (socket != null)
socket.close();
} catch (IOException e) {}
// program exit: tell somebody about that happening. Likely cause: server drops connection. // program exit: tell somebody about that happening. Likely cause: server drops connection.
System.out.println(); System.out.println();
System.out.println("TcpExample3Client exit"); System.out.println("TcpExample3Client exit");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment