def _configured_socket(address, options):
 sock = _create_connection(address, options)
 ssl_context = options.ssl_context
 if (ssl_context is not None):
  host = address[0]
  try:
   if (_HAVE_SNI and (not is_ip_address(host))):
    sock = ssl_context.wrap_socket(sock, server_hostname=host)
   else:
    sock = ssl_context.wrap_socket(sock)
  except IOError as exc:
   sock.close()
   raise ConnectionFailure(('SSL handshake failed: %s' % (str(exc),)))
  if (ssl_context.verify_mode and options.ssl_match_hostname):
   try:
    match_hostname(sock.getpeercert(), hostname=host)
   except CertificateError:
    sock.close()
    raise
 sock.settimeout(options.socket_timeout)
 return sock

def _configured_socket ( address , options ) : sock = _create_connection ( address , options ) ssl_context = options . ssl_context if ( ssl_context is not None ) : host = address [ 0 ] try : if ( _HAVE_SNI and ( not is_ip_address ( host ) ) ) : sock = ssl_context . wrap_socket ( sock , server_hostname = host ) else : sock = ssl_context . wrap_socket ( sock ) except IOError as exc : sock . close ( ) raise ConnectionFailure ( ( 'SSL handshake failed: %s' % ( str ( exc ) , ) ) ) if ( ssl_context . verify_mode and options . ssl_match_hostname ) : try : match_hostname ( sock . getpeercert ( ) , hostname = host ) except CertificateError : sock . close ( ) raise sock . settimeout ( options . socket_timeout ) return sock
given and pooloptions .