I suggest keeping create_raw_connection() a function, not loop's class method. After this change you don't need monkey-patching at all.
On Thursday, October 6, 2016 at 11:23:58 PM UTC+3, Olaf Conradi wrote: > > Hi, > > I'm working on an async version of a program that sends an ARP request and > waits for the response. > > To do that I need to open a raw socket. I monkey patched in two methods > two accomplish this: > create_raw_connection and _create_raw_connection_transport > See https://github.com/oohlaf/arp_aio/blob/master/arp_aio/arp.py#L25 up > to line 96. > > Not sure if this is the most elegant way? > Might it be worthwhile to add something like this to asyncio? > > Secondly, when I created my ArpRequestProtocol based on asyncio.Protocol > (line 128), I noticed that data_received seems to always be called for > every ethernet frame that is received. Is that always the case > (coincidence?), or is there a possibility that a frame starts midway into > the binary data argument? > > Best regards, > Olaf >
