Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

Unable to call recvfrom for raw ICMP socket #438

@foxx

Description

@foxx

Just spent a few hours reading over issues, mailing list threads and source code, trying to determine the best approach for receiving data on a raw ICMP socket.

icmp = socket.getprotobyname("icmp")
sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)

First suggestion was to use loop.add_reader() to listen for events, and then call sock.recvfrom() however this does not return any object reference, meaning I can't cancel the reader.

Second suggestion was to use loop.sock_recv(), but this does not return the addr like recvfrom() would, which is required for my use case.

Third was to use select.select(), but there were suggestions that this is the incorrect way to do things, and that you should be using streams and protocols instead. However there's no suitable stream/protocol class which I can use to listen for ICMP packets on a raw socket.

Someone submitted a PR to add recvfrom(), but it was rejected in favour of using create_datagram_endpoint(), which doesn't apply in my case.

Any thoughts/suggestions would be much appreciated, at the very least this warrants a docs patch to explain better how ICMP use cases should be handled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions