public Socket createSocket(InetAddress serverAddr, int serverPort,
InetAddress clientAddr, int clientPort)
throws IOException
{
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) factory.createSocket(serverAddr, serverPort, clientAddr, clientPort);
socket.addHandshakeCompletedListener(this);
socket.setNeedClientAuth(needsClientAuth);
socket.setWantClientAuth(wantsClientAuth);
return socket;
}