New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

abstract-socket

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-socket - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

24

lib/abstract_socket.js
var net = require('net');
var util = require('util');
var binding = require('bindings')('abstract_socket.node');

@@ -20,3 +21,9 @@

exports.startListening = function(path, connectionListener, listeningListener) {
function AbstractSocketServer(connectionListener) {
net.Server.call(this, connectionListener);
}
util.inherits(AbstractSocketServer, net.Server);
AbstractSocketServer.prototype.listen = function(name, listeningListener) {
var err = socket();

@@ -28,3 +35,3 @@ if (err < 0)

err = bind(err, path);
err = bind(err, name);
if (err < 0) {

@@ -35,9 +42,12 @@ close(handle.fd);

var server = net.createServer(connectionListener);
server.listen(handle, listeningListener);
return server;
net.Server.prototype.listen.call(this, handle, listeningListener);
};
exports.connect = function(path, connectListener) {
exports.createServer = function(connectionListener) {
return new AbstractSocketServer(connectionListener);
};
exports.connect = function(name, connectListener) {
var err = socket();

@@ -50,3 +60,3 @@ if (err < 0)

// yes, connect is synchronous, so sue me
err = connect(err, path);
err = connect(err, name);
if (err < 0) {

@@ -53,0 +63,0 @@ close(options.fd);

@@ -8,4 +8,4 @@ {

"name": "abstract-socket",
"version": "0.0.1",
"description": "Abstract domain socket support",
"version": "0.1.0",
"description": "Abstract domain socket support for Node",
"main": "lib/abstract_socket",

@@ -12,0 +12,0 @@ "homepage": "https://github.com/saghul/node-abstractsocket",

@@ -19,7 +19,3 @@ # node-abstractsocket

process.on('uncaughtException', function(err) {
console.log('Caught exception: ' + err);
});
var server = abs.startListening('\0foo', function(c) { //'connection' listener
var server = abs.createServer(function(c) { //'connection' listener
console.log('client connected');

@@ -32,2 +28,3 @@ c.on('end', function() {

});
server.listen('\0foo');

@@ -61,14 +58,22 @@ ```

### abs.startListening(name, connectionListener, [listeningListener])
### abs.createServer(connectionListener)
Returns a new net.Server object which has been bound to the given path
and it's already listening. NOTE: you must prepend the path with
Returns a new `AbstractSocketServer` object. `listen` can be called on
it passing the name of the abstract socket to bind to and listen, it follows
the API used for normal Unix domain sockets. NOTE: you must prepend the path with
the NULL byte ('\0') to indicate it's an abstract socket.
Throws an exception if the `socket(2)` or `listen(2)` system calls fail,
or the given `name` is invalid.
Throws an exception if the `socket(2)` system call fails.
The optional `listeningListener` argument is added as a listener for the
`'listening'` event.
### AbstractSocketServer.listen(name, [callback]
Binds the server to the specified abstract socket name.
Throws an exception if the `bind(2)` system call fails, or the given `name`
is invalid.
This function is asynchronous. When the server has been bound, 'listening' event
will be emitted. the last parameter callback will be added as an listener for the
'listening' event.
### abs.connect(name, connectListener)

@@ -83,3 +88,3 @@

Throws an exception if the `socket(2)` or `connect(2)` system calls fail,
or the given `name` is invalid;
or the given `name` is invalid.

@@ -91,1 +96,3 @@

@mmalecki taught me how to inherit like a pro.
var abs = require('./lib/abstract_socket');
process.on('uncaughtException', function(err) {
console.log('Caught exception: ' + err);
});
var server = abs.startListening('\0foo', function(c) { //'connection' listener
var server = abs.createServer(function(c) { //'connection' listener
console.log('client connected');

@@ -17,1 +13,2 @@ c.on('end', function() {

server.listen('\0foo');

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc