- Notifications
You must be signed in to change notification settings - Fork0
zhangyuang/abstract-socket-rs
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The ffi implemention ofabstract-socket based onffi-rs
- No need to use node-gyp 😊
- Pure javascript project ✨
- Pre build all platform output 🤯
- linux-x64-gnu
- linux-x64-musl
- linux-arm64-gnu
- linux-arm64-musl
The api interface is the same asabstract-socket.
Server:
// abstract echo serverconstabs=require('abstract-socket-rs');constserver=abs.createServer(function(c){//'connection' listenerconsole.log('client connected');c.on('end',function(){console.log('client disconnected');});c.write('hello\r\n');c.pipe(c);});server.listen('\0foo');
Client:
constabs=require('abstract-socket-rs');varclient=abs.connect('\0foo',function(){//'connect' listenerconsole.log('client connected');});client.on('data',function(data){console.log(data.toString());});process.stdin.setEncoding('utf8');process.stdin.on('readable',function(){constchunk=process.stdin.read();if(chunk!==null)client.write(chunk);});
Returns a newAbstractSocketServer
object.listen
can be called onit passing the name of the abstract socket to bind to and listen, it followsthe API used for normal Unix domain sockets. NOTE: you must prepend the path withthe NULL byte ('\0') to indicate it's an abstract socket.
Emits an error if thesocket(2)
system call fails.
Binds the server to the specified abstract socket name.
Emits an error if thebind(2)
system call fails, or the givenname
is invalid.
This function is asynchronous. When the server has been bound, 'listening' eventwill be emitted. the last parameter callback will be added as an listener for the'listening' event.
Creates a connection to the givenpath
in the abstract domain. NOTE: you mustprepend the path with the NULL byte ('\0') to indicate it's an abstractsocket.
Returns a new net.Socket object.
Emits an error if thesocket(2)
orconnect(2)
system calls fail,or the givenname
is invalid.
About
Implement abstract-socket based on ffi-rs without node-gyp
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.