Example #1
0
 public Socket newSocket() throws IOException {
   // zero means 'bind on any available port.'
   if (isEncryptedChannel()) {
     if (Config.getOutboundBindAny())
       return SSLFactory.getSocket(
           DatabaseDescriptor.getEncryptionOptions(),
           endPoint(),
           DatabaseDescriptor.getSSLStoragePort());
     else
       return SSLFactory.getSocket(
           DatabaseDescriptor.getEncryptionOptions(),
           endPoint(),
           DatabaseDescriptor.getSSLStoragePort(),
           FBUtilities.getLocalAddress(),
           0);
   } else {
     if (Config.getOutboundBindAny())
       return new Socket(endPoint(), DatabaseDescriptor.getStoragePort());
     else
       return new Socket(
           endPoint(), DatabaseDescriptor.getStoragePort(), FBUtilities.getLocalAddress(), 0);
   }
 }
 public Socket newSocket() throws IOException {
   // zero means 'bind on any available port.'
   if (isEncryptedChannel()) {
     if (Config.getOutboundBindAny())
       return SSLFactory.getSocket(
           DatabaseDescriptor.getServerEncryptionOptions(),
           endPoint(),
           DatabaseDescriptor.getSSLStoragePort());
     else
       return SSLFactory.getSocket(
           DatabaseDescriptor.getServerEncryptionOptions(),
           endPoint(),
           DatabaseDescriptor.getSSLStoragePort(),
           FBUtilities.getLocalAddress(),
           0);
   } else {
     Socket socket =
         SocketChannel.open(new InetSocketAddress(endPoint(), DatabaseDescriptor.getStoragePort()))
             .socket();
     if (Config.getOutboundBindAny() && !socket.isBound())
       socket.bind(new InetSocketAddress(FBUtilities.getLocalAddress(), 0));
     return socket;
   }
 }