Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Works on cPython too ? #1

Closed
sander76 opened this issue Feb 17, 2018 · 4 comments
Closed

Works on cPython too ? #1

sander76 opened this issue Feb 17, 2018 · 4 comments

Comments

@sander76
Copy link

If I understand correctly this code allows for getting the ip address of devices which are registered on mDNS with a certain name ?

If so I wonder whether this library can be adapted to work on "normal" python too (and more specifically on windows..) ? I did give it a go myself, but I failed..
I know there are libraries out there doing this already, but they are hard to install or are non-windows.

@nickovs
Copy link
Owner

nickovs commented Feb 17, 2018

Hi @sander76. Yes, this code allows others to find your IP address using mDNS. It absolutely can be made to work on cPython (and that's how I did most of my initial testing). The changes that are needed mostly are in the _make_socket() function where you need to set a bunch of other socket options. Adding this code into this version would increase the code size, so I'd rather not do it here but you are welcome to try.

That said, there are other projects for pure Python mDNS implementations which do not have small size as a primary goal. You should take a look at the standard Python ZeroConf library. This supports everything that my code does and a great deal more, at the expense of a much, much larger memory footprint, the need for threads and some rather less efficient packet handling. You can advertise your IP address (and other services) using the register_service() method of a Zeroconf object. The release notes indicate that it should work on Windows.

I hope that this helps.

@nickovs nickovs closed this as completed Feb 17, 2018
@sander76
Copy link
Author

@nickovs Thanks for the detailled response. The thing with ZeroConf library is that it requires NetIfaces. This is a library that cannot be just pip installed on windows: You need to compile it yourself or use a precompiled binary from https://www.lfd.uci.edu/~gohlke/pythonlibs/

As I am targeting windows users that is not a procedure I prefer.
I'll have a go with your suggestions... If you can share any more tips they are more than welcome !!

@nevercast
Copy link

Just linking this here for anyone that may want to try get slimDNS to work on their dev machine: https://gist.github.com/aaroncohen/4630685

I failed to get slimDNS running in Python 3.6 in Windows, and I couldn't afford the development time to investigate it further. I too suspect there is a missing socket option or the like that is required.

@nickovs
Copy link
Owner

nickovs commented Nov 20, 2018

If there is interest then I could certainly look at creating a version that is designed to work on other platforms. There seem to be three areas necessary to make this happen:

  1. Fixing my dumb bugs like struct.error: pack_into expected 6 items for packing (got 7) #4 which only manifest themselves when run on versions of python who's libraries perform more input checks than micropython does.
  2. Ensuring that the micropython-specific library functions like those in time.ticks_diff and time.ticks_ms are undefined. #5 are properly stubbed out.
  3. Probably the most complex: sorting out all of the various socket options that are needed to enable multicasting in different, platform-specific ways.

For the last item I can test on macOS and Linux but I'd need someone else to test the Windows version.

If people want to run slimDNS on full-size Python then click the smiley on this comment. If I get enough smiles I'll do it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants