当前位置: 首页>>代码示例>>Java>>正文


Java SSLServerSocket.setReuseAddress方法代码示例

本文整理汇总了Java中javax.net.ssl.SSLServerSocket.setReuseAddress方法的典型用法代码示例。如果您正苦于以下问题:Java SSLServerSocket.setReuseAddress方法的具体用法?Java SSLServerSocket.setReuseAddress怎么用?Java SSLServerSocket.setReuseAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.net.ssl.SSLServerSocket的用法示例。


在下文中一共展示了SSLServerSocket.setReuseAddress方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: open

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
@Override
public ServerChannel open(InetAddress address, int port, int timeout)
        throws IOException
{
    SSLServerSocket sock =
        (SSLServerSocket) _factory.createServerSocket(port,
                                                      _backlog, address);
    try {
        sock.setReuseAddress(_isReuseAddress);
        sock.setWantClientAuth(_isWantClientAuth);
        return new SSLServerChannel(sock, timeout);
    } catch (Throwable t) {
        if (!sock.isClosed()) {
            try {
                sock.close();
            } catch (Throwable tt) {
                t.addSuppressed(tt);
            }
        }
        throw t;
    }
}
 
开发者ID:perlundq,项目名称:yajsync,代码行数:23,代码来源:SSLServerChannelFactory.java

示例2: createSSLServerSocket

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public static SSLServerSocket createSSLServerSocket(Context context, int port) throws IOException {
	// get ssl context
	SSLContext sslcontext = null;
	try {
		sslcontext = initSSLContext(context);
	} catch (Exception e) {
		e.printStackTrace();
	}	
	
	// make secure Connection
    SSLServerSocketFactory factory = (SSLServerSocketFactory) sslcontext.getServerSocketFactory();
    SSLServerSocket sslServerSocket = (SSLServerSocket) factory.createServerSocket(port);
    if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN ) {
    	sslServerSocket.setEnabledProtocols(new String[] {"TLSv1","TLSv1.1","TLSv1.2"});
    }
    else {
    	sslServerSocket.setEnabledProtocols(new String[] {"TLSv1"});
    }
    sslServerSocket.setReuseAddress(true);
    
    return sslServerSocket;
}
 
开发者ID:screenfreeze,项目名称:deskcon-android,代码行数:23,代码来源:Connection.java

示例3: getServerSocket

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public static SSLServerSocket getServerSocket(EncryptionOptions options, InetAddress address, int port) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLServerSocket serverSocket = (SSLServerSocket)ctx.getServerSocketFactory().createServerSocket();
    serverSocket.setReuseAddress(true);
    String[] suits = filterCipherSuites(serverSocket.getSupportedCipherSuites(), options.cipher_suites);
    serverSocket.setEnabledCipherSuites(suits);
    serverSocket.setNeedClientAuth(options.require_client_auth);
    serverSocket.setEnabledProtocols(ACCEPTED_PROTOCOLS);
    serverSocket.bind(new InetSocketAddress(address, port), 500);
    return serverSocket;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:13,代码来源:SSLFactory.java

示例4: getServerSocket

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public static SSLServerSocket getServerSocket(EncryptionOptions options, InetAddress address, int port) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLServerSocket serverSocket = (SSLServerSocket)ctx.getServerSocketFactory().createServerSocket();
    serverSocket.setReuseAddress(true);
    String[] suits = filterCipherSuites(serverSocket.getSupportedCipherSuites(), options.cipher_suites);
    serverSocket.setEnabledCipherSuites(suits);
    serverSocket.setNeedClientAuth(options.require_client_auth);
    serverSocket.bind(new InetSocketAddress(address, port), 100);
    return serverSocket;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:12,代码来源:SSLFactory.java

示例5: getServerSocket

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public static SSLServerSocket getServerSocket(EncryptionOptions options, InetAddress address, int port) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLServerSocket serverSocket = (SSLServerSocket)ctx.getServerSocketFactory().createServerSocket();
    serverSocket.setReuseAddress(true);
    String[] suites = filterCipherSuites(serverSocket.getSupportedCipherSuites(), options.cipher_suites);
    serverSocket.setEnabledCipherSuites(suites);
    serverSocket.setNeedClientAuth(options.require_client_auth);
    serverSocket.setEnabledProtocols(ACCEPTED_PROTOCOLS);
    serverSocket.bind(new InetSocketAddress(address, port), 500);
    return serverSocket;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:13,代码来源:SSLFactory.java

示例6: getServerSocket

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public static SSLServerSocket getServerSocket(EncryptionOptions options, InetAddress address, int port) throws IOException
{
    SSLContext ctx = createSSLContext(options, true);
    SSLServerSocket serverSocket = (SSLServerSocket)ctx.getServerSocketFactory().createServerSocket();
    serverSocket.setReuseAddress(true);
    String[] suits = filterCipherSuites(serverSocket.getSupportedCipherSuites(), options.cipher_suites);
    serverSocket.setEnabledCipherSuites(suits);
    serverSocket.setNeedClientAuth(options.require_client_auth);
    serverSocket.bind(new InetSocketAddress(address, port), 500);
    return serverSocket;
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:12,代码来源:SSLFactory.java

示例7: createServerSocket

import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
private ServerSocket createServerSocket(int nport, int backlog, InetAddress bindAddr,
    int socketBufferSize, boolean sslConnection) throws IOException {
  printConfig();
  if (sslConnection) {
    if (this.sslContext == null) {
      throw new GemFireConfigException(
          "SSL not configured correctly, Please look at previous error");
    }
    ServerSocketFactory ssf = this.sslContext.getServerSocketFactory();
    SSLServerSocket serverSocket = (SSLServerSocket) ssf.createServerSocket();
    serverSocket.setReuseAddress(true);
    // If necessary, set the receive buffer size before binding the socket so
    // that large buffers will be allocated on accepted sockets (see
    // java.net.ServerSocket.setReceiverBufferSize javadocs)
    if (socketBufferSize != -1) {
      serverSocket.setReceiveBufferSize(socketBufferSize);
    }
    serverSocket.bind(new InetSocketAddress(bindAddr, nport), backlog);
    finishServerSocket(serverSocket);
    return serverSocket;
  } else {
    // log.info("Opening server socket on " + nport, new Exception("SocketCreation"));
    ServerSocket result = new ServerSocket();
    result.setReuseAddress(true);
    // If necessary, set the receive buffer size before binding the socket so
    // that large buffers will be allocated on accepted sockets (see
    // java.net.ServerSocket.setReceiverBufferSize javadocs)
    if (socketBufferSize != -1) {
      result.setReceiveBufferSize(socketBufferSize);
    }
    try {
      result.bind(new InetSocketAddress(bindAddr, nport), backlog);
    } catch (BindException e) {
      BindException throwMe =
          new BindException(LocalizedStrings.SocketCreator_FAILED_TO_CREATE_SERVER_SOCKET_ON_0_1
              .toLocalizedString(new Object[] {bindAddr, Integer.valueOf(nport)}));
      throwMe.initCause(e);
      throw throwMe;
    }
    return result;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:43,代码来源:SocketCreator.java


注:本文中的javax.net.ssl.SSLServerSocket.setReuseAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。