Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi!

As explain in another thread, on the unix port, the address returned by recvfrom() socket method is in the raw form (16 bytes).
A friend explained me it matches the C struct:

    struct sockaddr {
        sa_family_t sa_family;
        char        sa_data[14];
    }

In practice, this is an union, depending on the familly. For IPv4:

    struct sockaddr_in {
        sa_family_t    sin_family; /* address family: AF_INET */
        in_port_t      sin_port;   /* port in network byte order */
        struct in_addr sin_addr;   /* internet address */
    };

In my case, I get the raw data \x02\x00\x0e\x57\xc0\xa8\x00\x92\x00\x00\x00\x00\x00\x00\x00\x00 which matches ('192.168.0.146', 3671).

The question is: why the raw data isn't converted in a more useful tuple (ip, port) under the unix port, while it is on the rp2 port, for example, and on CPython? Is it a bug? A feature?

Thanks,

Frédéric

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.