服务器
decCipher.init(Cipher.DECCRYPT_MODE, secretKey);
ois = new ObjectInputStream(new CipherInputStream(socket.getInputStream(),decCipher));
encCipher.init(Cipher.ENCRYPT_MODE, secretKey);
out = new ObjectOutputStream(new CipherOutputStream(socket.getOutputStream(),encCipher));
客户端(不同的应用程序):
e
ncCipher.init(Cipher.ENCRYPT_MODE, secretKey);
obj_out = newObjectOutputStream(new CipherOutputStream(socket.getOutputStream(),encCipher));
decCipher.init(Cipher.DECRYPT_MODE, secretKey);
obj_in = new ObjectInputStream(new CipherInputStream(socket.getInputStream(),decCipher)
服务器应用程序中的 Ois 在创建流时引发异常。如何解决?当这没有包含在密码流中时,一切正常。
异常不会仅在创建时引发new ObjectInputStream
,而是冻结 10 秒(超时),当达到超时限制时会引发异常。
例外:
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2298)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2767)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:798)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:298)