davecheney / mdns

Multicast DNS library for Go
http://www.multicastdns.org/
BSD 2-Clause "Simplified" License
194 stars 30 forks source link

Implement using native system libraries and cgo. #10

Open leehambley opened 11 years ago

leehambley commented 11 years ago

So following my offer to get involved an improve the library, I'm wondering if we should implement a sane golang wrapper around the native system stuff that already exist for this in C.

(From O'Reilly Zeroconf Networking: The Definitive Guide) (or man (3) DNSServiceRegister)

DNSServiceErrorType DNSServiceRegister(
         DNSServiceRef *sdRef,
         DNSServiceFlags flags,
         uint32_t interfaceIndex,
         const char *name,
         const char *regtype,
         const char *domain,
         const char *host,
         uint16_t port,
         uint16_t txtLen,
         const void *txtRecord,
         DNSServiceRegisterReply callBack,
         void *context);

It's a callback driven API designed to be used with function pointers and an epoll/select loop around the underlying pseudo file descriptors returned by some of the other methods in the API.

Deferring to the C API might have some positive effects, such as completeness of the implementation, and robustness through having already made it into Linux, and supposedly having been tested and audited along the way.

The natural cons are that it's not supported in any way on Windows this way, where a native multicast DNS server (the likes of which you already have partially implemented) might be more portable.

davecheney commented 11 years ago

Hi Lee,

I'm not really interested in wrapping C code, you are welcome to fork this project if you think it would make a suitable base for an attempt to write bindings to avahi.

Cheers

Dave

On Tue, Jul 30, 2013 at 12:37 AM, Lee Hambley notifications@github.comwrote:

So following my offer to get involved an improve the library, I'm wondering if we should implement a sane golang wrapper around the native system stuff that already exist for this in C.

(From O'Reilly Zeroconf Networking: The Definitive Guidehttp://www.scribd.com/doc/63791209/Zero-Configuration-Networking-The-Definitive-Guide) (or man3 DNSServiceRegisterhttp://www.unix.com/man-page/all/3dns_sd/DNSServiceRegister/ )

DNSServiceErrorType DNSServiceRegister( DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, const char name, const char regtype, const char domain, const char host, uint16_t port, uint16_t txtLen, const void txtRecord, DNSServiceRegisterReply callBack, void *context);

It's a callback driven API designed to be used with function pointers and an epoll/select loop around the underlying pseudo file descriptors returned by some of the other methods in the API.

Deferring to the C API might have some positive effects, such as completeness of the implementation, and robustness through having already made it into Linux, and supposedly having been tested and audited along the way.

The natural cons are that it's not supported in any way on Windows this way, where a native multicast DNS server (the likes of which you already have partially implemented) might be more portable.

— Reply to this email directly or view it on GitHubhttps://github.com/davecheney/mdns/issues/10 .

leehambley commented 11 years ago

Hi Dave,

Having slept the night on it, you're probably right. The C API is messy, well - neat, as far as C goes, but wrapping function pointer callbacks in C and sharing the results with go-routines doesn't sound like much fun.

I'll probably stick to Go-lang when I ever find time to start writing code for this!

Cheers, Lee

Lee Hambley

http://lee.hambley.name/ +49 (0) 170 298 5667

On 30 July 2013 07:14, Dave Cheney notifications@github.com wrote:

Hi Lee,

I'm not really interested in wrapping C code, you are welcome to fork this project if you think it would make a suitable base for an attempt to write bindings to avahi.

Cheers

Dave

On Tue, Jul 30, 2013 at 12:37 AM, Lee Hambley notifications@github.comwrote:

So following my offer to get involved an improve the library, I'm wondering if we should implement a sane golang wrapper around the native system stuff that already exist for this in C.

(From O'Reilly Zeroconf Networking: The Definitive Guide< http://www.scribd.com/doc/63791209/Zero-Configuration-Networking-The-Definitive-Guide>)

(or man3 DNSServiceRegister< http://www.unix.com/man-page/all/3dns_sd/DNSServiceRegister/> )

DNSServiceErrorType DNSServiceRegister( DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, const char name, const char regtype, const char domain, const char host, uint16_t port, uint16_t txtLen, const void txtRecord, DNSServiceRegisterReply callBack, void *context);

It's a callback driven API designed to be used with function pointers and an epoll/select loop around the underlying pseudo file descriptors returned by some of the other methods in the API.

Deferring to the C API might have some positive effects, such as completeness of the implementation, and robustness through having already made it into Linux, and supposedly having been tested and audited along the way.

The natural cons are that it's not supported in any way on Windows this way, where a native multicast DNS server (the likes of which you already have partially implemented) might be more portable.

— Reply to this email directly or view it on GitHub< https://github.com/davecheney/mdns/issues/10> .

— Reply to this email directly or view it on GitHubhttps://github.com/davecheney/mdns/issues/10#issuecomment-21770121 .