S
Scott W Gifford
Hello,
I'm writing a multi-threaded application that uses SSL sockets for
communication. I'm wondering if I need to provide any synchronization
around the SocketFactory returned by SSLSocketFactory.getDefault(), if
it's possible many threads will be creating new connections
simultaneously? Can they all use the same SocketFactory, or should
they each call SSLSocketFactory.getDefault() to get their own?
Currently, my client provides methods like these:
private static SocketFactory sockFac = null;
private static SocketFactory getSocketFac() {
if (sockFac == null)
sockFac = SSLSocketFactory.getDefault();
return sockFac;
}
public SearchClient(InetAddress host, int port) throws IOException {
this(getSocketFac().createSocket(host,port));
}
Should this be thread-safe?
Thanks!
----ScottG.
I'm writing a multi-threaded application that uses SSL sockets for
communication. I'm wondering if I need to provide any synchronization
around the SocketFactory returned by SSLSocketFactory.getDefault(), if
it's possible many threads will be creating new connections
simultaneously? Can they all use the same SocketFactory, or should
they each call SSLSocketFactory.getDefault() to get their own?
Currently, my client provides methods like these:
private static SocketFactory sockFac = null;
private static SocketFactory getSocketFac() {
if (sockFac == null)
sockFac = SSLSocketFactory.getDefault();
return sockFac;
}
public SearchClient(InetAddress host, int port) throws IOException {
this(getSocketFac().createSocket(host,port));
}
Should this be thread-safe?
Thanks!
----ScottG.