File tree 1 file changed +16
-1
lines changed
webcam-capture/src/main/java/com/github/sarxos/webcam
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 8
8
import java .io .InputStreamReader ;
9
9
import java .net .ServerSocket ;
10
10
import java .net .Socket ;
11
+ import java .net .SocketException ;
11
12
import java .util .concurrent .Executor ;
12
13
import java .util .concurrent .Executors ;
13
14
import java .util .concurrent .ThreadFactory ;
@@ -123,6 +124,13 @@ public void run() {
123
124
124
125
do {
125
126
127
+ if (socket .isInputShutdown ()) {
128
+ break ;
129
+ }
130
+ if (socket .isClosed ()) {
131
+ break ;
132
+ }
133
+
126
134
baos .reset ();
127
135
128
136
ImageIO .write (getImage (), "JPG" , baos );
@@ -136,7 +144,14 @@ public void run() {
136
144
bos .write (sb .toString ().getBytes ());
137
145
bos .write (baos .toByteArray ());
138
146
bos .write (CRLF .getBytes ());
139
- bos .flush ();
147
+
148
+ try {
149
+ bos .flush ();
150
+ } catch (SocketException e ) {
151
+ if (!socket .isClosed ()) {
152
+ throw e ;
153
+ }
154
+ }
140
155
141
156
Thread .sleep (getDelay ());
142
157
You can’t perform that action at this time.
0 commit comments