All Projects → saghul → node-abstractsocket

saghul / node-abstractsocket

Licence: MIT License
Abstract namespace socket support for Node

Programming Languages

javascript
184084 projects - #8 most used programming language
C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to node-abstractsocket

game net
Unity游戏和C++服务器 socket通信demo, 数据格式采用google protobuf
Stars: ✭ 53 (+120.83%)
Mutual labels:  socket
laravel-redis-chat
Real Time Chat with Laravel, Node.js, Redis and Socket.io
Stars: ✭ 84 (+250%)
Mutual labels:  socket
memsocket
An asynchronous in-memory socket-like interface for Rust
Stars: ✭ 34 (+41.67%)
Mutual labels:  socket
EasyFileTransfer
An easy way to transfer file with any size on network with tcp protocol.
Stars: ✭ 30 (+25%)
Mutual labels:  socket
UnityWebSocket
🐳 The Best Unity WebSocket Plugin for All Platforms.
Stars: ✭ 321 (+1237.5%)
Mutual labels:  socket
KTV
KTV系统,C#前后台,Android客户端。播放器使用迅雷开源APlayer播放引擎。
Stars: ✭ 33 (+37.5%)
Mutual labels:  socket
chattt-backend
🖥 Backend for chattt
Stars: ✭ 17 (-29.17%)
Mutual labels:  socket
chat-server
💬 [WIP] Simple Chat Server built with React, Node, Express and Socket.io
Stars: ✭ 18 (-25%)
Mutual labels:  socket
BaseIotUtils
🔥🔥串口工具,屏幕适配,通知工具类,多文件断点下载,xls,xlsx操作,文件处理,crash控制,音视频播放,usb设备检测,adb工具等...
Stars: ✭ 44 (+83.33%)
Mutual labels:  socket
ddos
Simple dos attack utility
Stars: ✭ 36 (+50%)
Mutual labels:  socket
Tiginx
Tiginx is a Shanzhai Nginx project , please buyao use it xian , if meet problem , I no fuze ...
Stars: ✭ 29 (+20.83%)
Mutual labels:  socket
Vutils
Vutils or Vic Utilities is an utility library written in Modern C++ and for Modern C++. It helps your programming go easier, faster, and simpler.
Stars: ✭ 16 (-33.33%)
Mutual labels:  socket
SockNet
The easiest and fastest way to work with sockets in C#
Stars: ✭ 42 (+75%)
Mutual labels:  socket
Stone
A Swift framework for connecting to Phoenix Channels in your iOS app (with Presence support).
Stars: ✭ 18 (-25%)
Mutual labels:  socket
realgpserver
程序采用Python语言进行编写开发,用来接收GPS原始数据,并进行解析入库Mysql。主要用到SocketServer,log,command,dbhandler,config几个模块。
Stars: ✭ 13 (-45.83%)
Mutual labels:  socket
video-group-meeting
WebRTC video chat for multi users using React and Node Express.
Stars: ✭ 40 (+66.67%)
Mutual labels:  socket
docker-testssl
http://testssl.sh/ in a tiny docker container
Stars: ✭ 19 (-20.83%)
Mutual labels:  socket
as2-server
A standalone Java AS2 server - see as2-lib for the generic parts
Stars: ✭ 29 (+20.83%)
Mutual labels:  socket
fire-im
分布式IM服务,参考https://github.com/crossoverJie/cim 实现
Stars: ✭ 17 (-29.17%)
Mutual labels:  socket
Symbol
Symbol .net library
Stars: ✭ 14 (-41.67%)
Mutual labels:  socket

node-abstractsocket

Because I like my sockets like my Picasso paintings: abstract.

NPM

Abstract what?

Go read this: http://man7.org/linux/man-pages/man7/unix.7.html, I'll wait.

Examples

Server:

// abstract echo server
const abs = require('./lib/abstract_socket');

const server = abs.createServer(function(c) { //'connection' listener
  console.log('client connected');
  c.on('end', function() {
    console.log('client disconnected');
  });
  c.write('hello\r\n');
  c.pipe(c);
});
server.listen('\0foo');

Client:

const abs = require('./lib/abstract_socket');

var client = abs.connect('\0foo', function() { //'connect' listener
    console.log('client connected');
});

client.on('data', function(data) {
    console.log(data.toString());
});

process.stdin.setEncoding('utf8');
process.stdin.on('readable', function() {
    const chunk = process.stdin.read();
    if (chunk !== null)
        client.write(chunk);
});

API

abs.createServer(connectionListener)

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.

Emits an error if the socket(2) system call fails.

AbstractSocketServer.listen(name, [callback]

Binds the server to the specified abstract socket name.

Emits an error 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)

Creates a connection to the given path in the abstract domain. NOTE: you must prepend the path with the NULL byte ('\0') to indicate it's an abstract socket.

Returns a new net.Socket object.

Emits an error if the socket(2) or connect(2) system calls fail, or the given name is invalid.

Tests

Run tests with npm test.

Thanks

I borrowed massive amounts of inspiration/code from node-unix-dgram by @bnoordhuis :-)

@mmalecki taught me how to inherit like a pro. @randunel refactored it heavily in v2.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].