{"id":16156844,"url":"https://github.com/saghul/node-abstractsocket","last_synced_at":"2025-03-16T09:33:42.619Z","repository":{"id":18631447,"uuid":"21837584","full_name":"saghul/node-abstractsocket","owner":"saghul","description":"Abstract namespace socket support for Node","archived":false,"fork":false,"pushed_at":"2019-11-15T15:44:08.000Z","size":37,"stargazers_count":24,"open_issues_count":3,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-27T07:13:23.929Z","etag":null,"topics":["javascript","nodejs","socket"],"latest_commit_sha":null,"homepage":"","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/saghul.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":"2014-07-14T22:15:52.000Z","updated_at":"2023-06-10T07:18:52.000Z","dependencies_parsed_at":"2022-09-11T17:03:11.601Z","dependency_job_id":null,"html_url":"https://github.com/saghul/node-abstractsocket","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saghul%2Fnode-abstractsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saghul%2Fnode-abstractsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saghul%2Fnode-abstractsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saghul%2Fnode-abstractsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saghul","download_url":"https://codeload.github.com/saghul/node-abstractsocket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809888,"owners_count":20351407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["javascript","nodejs","socket"],"created_at":"2024-10-10T01:46:45.680Z","updated_at":"2025-03-16T09:33:42.201Z","avatar_url":"https://github.com/saghul.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-abstractsocket\n\nBecause I like my sockets like my Picasso paintings: abstract.\n\n[![NPM](https://nodei.co/npm/abstract-socket.png)](https://nodei.co/npm/abstract-socket/)\n\n\n## Abstract what?\n\nGo read this: http://man7.org/linux/man-pages/man7/unix.7.html, I'll wait.\n\n\n## Examples\n\nServer:\n\n```js\n// abstract echo server\nconst abs = require('./lib/abstract_socket');\n\nconst server = abs.createServer(function(c) { //'connection' listener\n  console.log('client connected');\n  c.on('end', function() {\n    console.log('client disconnected');\n  });\n  c.write('hello\\r\\n');\n  c.pipe(c);\n});\nserver.listen('\\0foo');\n\n```\n\nClient:\n\n```js\nconst abs = require('./lib/abstract_socket');\n\nvar client = abs.connect('\\0foo', function() { //'connect' listener\n    console.log('client connected');\n});\n\nclient.on('data', function(data) {\n    console.log(data.toString());\n});\n\nprocess.stdin.setEncoding('utf8');\nprocess.stdin.on('readable', function() {\n    const chunk = process.stdin.read();\n    if (chunk !== null)\n        client.write(chunk);\n});\n\n```\n\n\n## API\n\n### abs.createServer(connectionListener)\n\nReturns a new `AbstractSocketServer` object. `listen` can be called on\nit passing the name of the abstract socket to bind to and listen, it follows\nthe API used for normal Unix domain sockets. NOTE: you must prepend the path with\nthe NULL byte ('\\0') to indicate it's an abstract socket.\n\nEmits an error if the `socket(2)` system call fails.\n\n### AbstractSocketServer.listen(name, [callback]\n\nBinds the server to the specified abstract socket name.\n\nEmits an error if the `bind(2)` system call fails, or the given `name`\nis invalid.\n\nThis function is asynchronous. When the server has been bound, 'listening' event\nwill be emitted. the last parameter callback will be added as an listener for the\n'listening' event.\n\n### abs.connect(name, connectListener)\n\nCreates a connection to the given `path` in the abstract domain. NOTE: you must\nprepend the path with the NULL byte ('\\0') to indicate it's an abstract\nsocket.\n\nReturns a new net.Socket object.\n\nEmits an error if the `socket(2)` or `connect(2)` system calls fail,\nor the given `name` is invalid.\n\n## Tests\n\nRun tests with `npm test`.\n\n## Thanks\n\nI borrowed massive amounts of inspiration/code from node-unix-dgram by @bnoordhuis :-)\n\n@mmalecki taught me how to inherit like a pro.\n@randunel refactored it heavily in v2.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaghul%2Fnode-abstractsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaghul%2Fnode-abstractsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaghul%2Fnode-abstractsocket/lists"}