def wrap_socket(sock, server_hostname, ssl_context=None, force_proto=None):
    "\n    A vastly simplified SSL wrapping function. We'll probably extend this to\n    do more things later.\n    "
    global _context
    if ssl_context:
        _ssl_context = ssl_context
    else:
        if (_context is None):
            _context = init_context()
        _ssl_context = _context
    ssl_sock = _ssl_context.wrap_socket(sock, server_hostname=server_hostname)
    if _ssl_context.check_hostname:
        try:
            ssl.match_hostname(ssl_sock.getpeercert(), server_hostname)
        except AttributeError:
            ssl.verify_hostname(ssl_sock, server_hostname)
    proto = force_proto
    with ignore_missing():
        if (proto is None):
            proto = ssl_sock.selected_alpn_protocol()
    with ignore_missing():
        if (proto is None):
            proto = ssl_sock.selected_npn_protocol()
    return (ssl_sock, proto)
A vastly simplified SSL wrapping function. We'll probably extend this to
do more things later.
def wrap_socket(sock, server_hostname, ssl_context=None, force_proto=None):
    "\n    A vastly simplified SSL wrapping function. We'll probably extend this to\n    do more things later.\n    "
    global _context
    if ssl_context:
        _ssl_context = ssl_context
    else:
        if (_context is None):
            _context = init_context()
        _ssl_context = _context
    ssl_sock = _ssl_context.wrap_socket(sock, server_hostname=server_hostname)
    if _ssl_context.check_hostname:
        try:
            ssl.match_hostname(ssl_sock.getpeercert(), server_hostname)
        except AttributeError:
            ssl.verify_hostname(ssl_sock, server_hostname)
    proto = force_proto
    with ignore_missing():
        if (proto is None):
            proto = ssl_sock.selected_alpn_protocol()
    with ignore_missing():
        if (proto is None):
            proto = ssl_sock.selected_npn_protocol()
    return (ssl_sock, proto)