Skip to content

silberGuy/justcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JusTCP

A simple way to send and receive buffers over tcp sockets, using promises, and without concerning sizes.

const { JuSocket } = require('../JuSocket');

// Server

const server = net.createServer(async socket => {
    const sock = JuSocket(socket);
    while (1) {
        const req = await sock.waitForMessage();
        const response = await doServerLogic();
        sock.sendBuffer(response);
    }
});
server.listen('127.0.0.1', 1234);

// Client
(async function() {
    const socket = net.connect('127.0.0.1', 1234);
    const sock = JuSocket(socket);

    const response = await sock.sendBufferAndReceive(Buffer.from('Hello Server'));
    console.log(response.toString());
})();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published