小编Huy*_*ynh的帖子

websocket握手源代码中的laddr和raddr是什么

我正在学习 websocket 在 python 3 中的工作原理。我在 websocket 源代码中添加了 print(sock) 到 _handshake.py 的 def 握手,以了解 sock 中的消息是什么,结果是这样的:

Print out sock:<ssl.SSLSocket fd=508, family=AddressFamily.AF_INET, type=0, proto=0, laddr=('192.168.1.2', 58730), raddr=('202.160.125.211', 443)>
Run Code Online (Sandbox Code Playgroud)

我想知道 laddr 和 raddr 是什么?我知道这太基础了,但没有扎实的背景,因为我似乎很难理解我已经在 gg 中搜索了这些关键字,但没有解释。

def handshake(sock, hostname, port, resource, **options):
    headers, key = _get_handshake_headers(resource, hostname, port, options)
    header_str = "\r\n".join(headers)
    send(sock, header_str)
    dump("request header", header_str)
    print("Print out sock:{}".format(sock))
    status, resp = _get_resp_headers(sock)
    if status in SUPPORTED_REDIRECT_STATUSES:
        return handshake_response(status, resp, None)
    success, subproto = _validate(resp, key, options.get("subprotocols"))
    if not success:
        raise …
Run Code Online (Sandbox Code Playgroud)

websocket python-3.x handshake

6
推荐指数
1
解决办法
3084
查看次数

标签 统计

handshake ×1

python-3.x ×1

websocket ×1