Skip to content

GeekBerry/buffer-socket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buffer socket

Buffer input output framework base on websocket.

Usage

  • server
const { Server, Client } = require('@geekberry/buffer-socket');

const server = new Server(
  { host: '127.0.0.1', port: 6080, checkAliveInterval:30*1000 }, 
  (input, output) =>{
    output.write(input.toBuffer().reverse());
  }
);
  • client
const client = new Client({ host: '127.0.0.1', port: 6080 });

const stream = await client.request(Buffer.from('1234'));

console.log(stream.toBuffer().toString()); // 4321

Package structure:

  • request:
length note
4 bytes requestId
N bytes data
  • response:
length note
4 bytes requestId
4 bytes SUCCESS
N bytes data
  • error:
length note
4 bytes requestId
4 bytes ERROR
N bytes error message

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published