I once needed a simple library for a project to convert a printable IP address into binary form and vice versa. In C, you can do this with inet_pton() and inet_ntop() functions, same is true for PHP. I was rather surprised that Node does not have a native implementation of these functions. I needed something very simple, fast, and without extra dependencies.

However, I failed to find what I need on npmjs, and then decided to write a simple addon for Node.js. That was my very first attempt to write an addon, so I had to lear a lot of new things: v8 API, Node API, node-gyp, nan.

In the end, I wrote a simple addon, inet_xtoy. I tested it on Node 6, 8, 10, and 12. It is probably Linux-only (I don’t have a Windows box around), but probably works on MacOS as well. Its source code is available on GitHub.

I hope that someone will find it useful 🙂

inet_xtoy: inet_ntop() and inet_pton() bindings for Node.js
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *