Skip to content

Commit f17af19

Browse files
committed
updated OutputStreamThread.java
1 parent 8aff94e commit f17af19

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/de/javasocketapi/core/OutputStreamThread.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.IOException;
44
import java.io.OutputStream;
55
import java.net.Socket;
6+
import java.net.SocketException;
67
import java.util.LinkedList;
78
import java.util.List;
89
import java.util.Timer;
@@ -69,20 +70,26 @@ public void run() {
6970
//initialise packet
7071
packet.send(writingByteBuffer);
7172
}
72-
//receive bytes
73-
byte[] bytes = writingByteBuffer.toBytes();
74-
//check if outputstream is null
75-
assert finalOutputStream != null;
76-
//write bytes length
77-
finalOutputStream.write(bytes.length);
78-
//write bytes
79-
finalOutputStream.write(bytes);
80-
//flush outputStream
81-
finalOutputStream.flush();
73+
try {
74+
//receive bytes
75+
byte[] bytes = writingByteBuffer.toBytes();
76+
//check if outputstream is null
77+
assert finalOutputStream != null;
78+
//write bytes length
79+
finalOutputStream.write(bytes.length);
80+
//write bytes
81+
finalOutputStream.write(bytes);
82+
//flush outputStream
83+
finalOutputStream.flush();
84+
} catch (SocketException ignored) {
85+
86+
}
8287
}
8388
}
8489
} catch (IOException e) {
8590
e.printStackTrace();
91+
} catch (NullPointerException ignored) {
92+
8693
}
8794
}
8895
}, 0, 1);

0 commit comments

Comments
 (0)