eclipse / paho.mqtt.python

paho.mqtt.python
Other
2.12k stars 722 forks source link

add support for "unix" transport where socket module contains AF_UNIX #829

Closed akrpic77 closed 2 months ago

akrpic77 commented 3 months ago

This pull request adds "unix" transport where underlying python's socket module contains AF_UNIX constant. This is, of course, available on all the unices, and since 2017 on Windows 10 too. Although support for it has not yet landed in the cpython.

The use case for this transport is when both broker and client run on the same machine - unix sockets should provide noticable performance gains.

Few remarks: 1) unix socket is created instead of normal socket, so it is possible to create tls over unix socket, but that is not tested 2) for client tests, the fake_broker is parametrized for 'tcp', and 'unix', this could also be used for e.g. 'tcp6' test 3) unix socket filename is currently 'localhost', so it wasn't necessary to modify connect* methods. I don't like it, maybe fake_broker.addr can be added as a tuple with value (host, port) for "tcp" , and (path,) for "unix". This addr field would also come handy later if "tcp6" tests are added.

PierreF commented 3 months ago

Hello, thanks for your contribution. Could you sign the Eclipse ECA for your contribution to be merged (https://accounts.eclipse.org/user/eca) ?

akrpic77 commented 3 months ago

Done!