{"id":24143351,"url":"https://github.com/little-core-labs/ioctl-native","last_synced_at":"2026-05-13T03:37:13.354Z","repository":{"id":57275815,"uuid":"192401835","full_name":"little-core-labs/ioctl-native","owner":"little-core-labs","description":"A simple N-API native node module for the ioctl function","archived":false,"fork":false,"pushed_at":"2019-06-17T19:04:48.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-01T13:43:21.732Z","etag":null,"topics":["addon","ioctl","napi","native","node"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/little-core-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-17T18:54:14.000Z","updated_at":"2019-12-19T16:33:03.000Z","dependencies_parsed_at":"2022-09-15T19:10:21.659Z","dependency_job_id":null,"html_url":"https://github.com/little-core-labs/ioctl-native","commit_stats":null,"previous_names":["jwerle/ioctl-native"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/little-core-labs/ioctl-native","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fioctl-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fioctl-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fioctl-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fioctl-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/little-core-labs","download_url":"https://codeload.github.com/little-core-labs/ioctl-native/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fioctl-native/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32967208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T23:30:32.555Z","status":"online","status_checked_at":"2026-05-13T02:00:07.132Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["addon","ioctl","napi","native","node"],"created_at":"2025-01-12T05:15:17.825Z","updated_at":"2026-05-13T03:37:13.339Z","avatar_url":"https://github.com/little-core-labs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ioctl-native\n============\n\nA simple N-API native node module for the ioctl function\n\n## Installation\n\n```sh\n$ npm install ioctl-native\n```\n\n## Usage\n\n```js\nconst ioctl = require('ioctl-native'\nrc = ioctl(fd, request, argp)\n```\n\n## API\n\n### `rc = ioctl(fd, request, argp)`\n\nIssue a request to a device specified by the file descriptor `fd` with\nan argument poinrter `argp` that should be an instance of a `Buffer`.\n\n_Below is an example request to **get the number of bytes in the\ninput buffer**:_\n\n```js\nconst FIONREAD = 0x541b\nconst status = Buffer.alloc(4) // 32 bit int (little endian)\nconst fd = getSocketFileDescriptor()\n\nassert(0 === ioctl(fd, FIONREAD, status))\n\nconst pendingReads = status.readInt32LE(0)\n```\n\n## Example\n\nThe following is an [example](example.js) that creates two sockets, one\nthat is bound to an address and port, and the other that writes a\n`hello` message of length `5`. The example queries the pending number of\nbytes in the input buffer for the _reader socket_ (`sockets.reader`) and\nlogs it out.\n\n```js\nconst assert = require('assert')\nconst dgram = require('dgram')\nconst ioctl = require('ioctl-native')\nconst fs = require('fs')\n\nconst FIONREAD = 0x541b\nconst hello = Buffer.from('hello')\nconst status = Buffer.alloc(4) // 32 bit int (little endian)\nconst sockets = {\n  reader: dgram.createSocket('udp4'),\n  writer: dgram.createSocket('udp4'),\n}\n\nsockets.reader.bind(0, (err) =\u003e {\n  const { address, port } = sockets.reader.address()\n\n  sockets.writer.send(hello, 0, hello.length, port, address, (err) =\u003e {\n    assert(0 === ioctl(sockets.reader._handle.fd, FIONREAD, status))\n    const pending = status.readInt32LE(0)\n\n    console.log('\u003e %d bytes pending in reader socket', pending) // pending == hello.length\n\n    sockets.reader.close()\n    sockets.writer.close()\n  })\n})\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittle-core-labs%2Fioctl-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittle-core-labs%2Fioctl-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittle-core-labs%2Fioctl-native/lists"}