|
5 | 5 | */ |
6 | 6 | packageorg.java_websocket; |
7 | 7 |
|
| 8 | +importjavax.net.ssl.SSLEngine; |
| 9 | +importjavax.net.ssl.SSLEngineResult; |
| 10 | +importjavax.net.ssl.SSLEngineResult.HandshakeStatus; |
| 11 | +importjavax.net.ssl.SSLEngineResult.Status; |
| 12 | +importjavax.net.ssl.SSLException; |
| 13 | +importjavax.net.ssl.SSLSession; |
| 14 | +importjava.io.EOFException; |
8 | 15 | importjava.io.IOException; |
9 | 16 | importjava.net.Socket; |
10 | 17 | importjava.net.SocketAddress; |
|
20 | 27 | importjava.util.concurrent.ExecutorService; |
21 | 28 | importjava.util.concurrent.Future; |
22 | 29 |
|
23 | | -importjavax.net.ssl.SSLEngine; |
24 | | -importjavax.net.ssl.SSLEngineResult; |
25 | | -importjavax.net.ssl.SSLEngineResult.HandshakeStatus; |
26 | | -importjavax.net.ssl.SSLEngineResult.Status; |
27 | | -importjavax.net.ssl.SSLException; |
28 | | -importjavax.net.ssl.SSLSession; |
29 | | - |
30 | 30 | /** |
31 | 31 | * Implements the relevant portions of the SocketChannel interface with the SSLEngine wrapper. |
32 | 32 | */ |
@@ -213,6 +213,9 @@ public int write( ByteBuffer src ) throws IOException{ |
213 | 213 | // createBuffers( sslEngine.getSession() ); |
214 | 214 | //} |
215 | 215 | intnum = socketChannel.write( wrap( src ) ); |
| 216 | +if (writeEngineResult.getStatus() == SSLEngineResult.Status.CLOSED){ |
| 217 | +thrownewEOFException("Connection is closed"); |
| 218 | + } |
216 | 219 | returnnum; |
217 | 220 |
|
218 | 221 | } |
@@ -286,6 +289,9 @@ private int readRemaining( ByteBuffer dst ) throws SSLException{ |
286 | 289 | if( inCrypt.hasRemaining() ){ |
287 | 290 | unwrap(); |
288 | 291 | intamount = transfereTo( inData, dst ); |
| 292 | +if (readEngineResult.getStatus() == SSLEngineResult.Status.CLOSED){ |
| 293 | +return -1; |
| 294 | + } |
289 | 295 | if( amount > 0 ) |
290 | 296 | returnamount; |
291 | 297 | } |
|
0 commit comments