File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/main/java/org/java_websocket Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -197,6 +197,10 @@ public int write( ByteBuffer src ) throws IOException {
197
197
198
198
}
199
199
200
+ /**
201
+ * Blocks when in blocking mode until at least one byte has been decoded.<br>
202
+ * When not in blocking mode 0 may be returned.
203
+ **/
200
204
public int read ( ByteBuffer dst ) throws IOException {
201
205
if ( !dst .hasRemaining () )
202
206
return 0 ;
@@ -231,8 +235,12 @@ public int read( ByteBuffer dst ) throws IOException {
231
235
}
232
236
inCrypt .flip ();
233
237
unwrap ();
234
- return transfereTo ( inData , dst );
235
238
239
+ int transfered = transfereTo ( inData , dst );
240
+ if ( transfered == 0 && isBlocking () ) {
241
+ return read ( dst ); // "transfered" may be 0 when not enough bytes were received or during rehandshaking
242
+ }
243
+ return transfered ;
236
244
}
237
245
238
246
private int readRemaining ( ByteBuffer dst ) throws SSLException {
You can’t perform that action at this time.
0 commit comments