what is laddr and raddr in handshake souce code of websocket
Asked Answered
T

1

8

I am learning how websocket works in python 3. I add print(sock) to def handshake of _handshake.py in websocket source to learn what is the message inside sock And the result is sth like this:

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)>

I wonder what laddr and raddr is? I know that is too basic but without solid background as me it appears complicated to understand I have searched gg for those keywords but there is no explaination.

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 WebSocketException("Invalid WebSocket Header")
    return handshake_response(status, resp, subproto)
Tussle answered 25/6, 2019 at 7:41 Comment(0)
R
14

laddr means local address and raddr means remote address of the socket. Depending on the context of the process or application, one address becomes the remote to the other socket.

Rincon answered 25/6, 2019 at 8:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.