thank you very much - this post is exactly what I need. Python supports recvmsg, and sendmsg from version 3.3, but Twisted has its own implementation that is 2.7 compatible. I'll try that right away. I think it's best to include the recvmsg/sendmsg code into my DatagramProtocol subclass.

Best Regards

2013/10/16 Richard Wall <>
On 16 October 2013 12:47, Itamar Turner-Trauring <> wrote:
> On 10/16/2013 03:36 AM, Maciej Wasilak wrote:
>> All in all the problem with using wrong source address can be easilly
>> solved with a bit of user attention, however it's hard to find the solution
>> that "just works".
> There's an OS API (recvmsg?) that lets you get at this information; I
> believe Twisted has the start of a wrapper for it. Given a full wrapper we
> could create a new UDP API that did support this easily.

Here's a good description of how PowerDNS solved this problem using recvmsg:

I don't think it's currently possible to listenUDP on a specific IPv6 address:

But the branch for that ticket is almost ready to be merged... it just
needs a few custom exception classes I think.


Twisted-Python mailing list