sslsocket getInputStream() == Slow ?

C

cmk128

Hi
For SSLSocket, the getInputStream method is very slow, running on XP
with jdk1.5

BufferedReader in = new BufferedReader(new
InputStreamReader(sslSocket.getInputStream()));

If i change to socket, it is very fast.


Here is my compile code:

new Thread() {
public void run() {
SSLSocketFactory sslFactory = (SSLSocketFactory)
SSLSocketFactory.getDefault();
for (int i = 0; time < 10000; i++) {
SSLSocket sslSocket = null;
try {
sslSocket = (SSLSocket)
sslFactory.createSocket("localhost", 8080);
} catch (Exception ex) {
ex.printStackTrace();
continue;
}
try {

BufferedReader in = new BufferedReader(new
InputStreamReader(
sslSocket.getInputStream()));
in.close();
sslSocket.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}.start();



thanks
from Peter ([email protected])
 
S

shakah

Hi
For SSLSocket, the getInputStream method is very slow, running on XP
with jdk1.5

BufferedReader in = new BufferedReader(new
InputStreamReader(sslSocket.getInputStream()));

If i change to socket, it is very fast.


Here is my compile code:

new Thread() {
public void run() {
SSLSocketFactory sslFactory = (SSLSocketFactory)
SSLSocketFactory.getDefault();
for (int i = 0; time < 10000; i++) {
SSLSocket sslSocket = null;
try {
sslSocket = (SSLSocket)
sslFactory.createSocket("localhost", 8080);
} catch (Exception ex) {
ex.printStackTrace();
continue;
}
try {

BufferedReader in = new BufferedReader(new
InputStreamReader(
sslSocket.getInputStream()));
in.close();
sslSocket.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}.start();



thanks
from Peter ([email protected])

Not sure what you mean by "very slow", but calling getInputStream() for
an SSL socket probably blocks until the certificate and key exchanges
have completed. Those certainly take longer than the
no-exchange-necessary situation in a plain vanilla socket.
 
C

cmk128

without getInputStream() , i can open and close a sslsocke 30 times per
second.
After calling getInputStream(), the speed down to 0.5 times per second.
thanks
 
E

Esmond Pitt

without getInputStream() , i can open and close a sslsocke 30 times per
second.
After calling getInputStream(), the speed down to 0.5 times per second.

Security costs time, and TLS/SSL is *extremely* secure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top