We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const net = require('net'); const { Client } = require('yamux-js'); const nbStreams = 3; const socket = net.createConnection(3500, () => { console.log('Connected on port', socket.localPort); const yamuxClient = new Client(); socket.pipe(yamuxClient).pipe(socket); for (let i = 0; i < nbStreams; i++) { const stream = yamuxClient.open(); const prefix = `[Stream ${stream.ID()}]`; stream.on('end', () => console.log(`${prefix} Stream end`)); stream.on('close', () => console.log(`${prefix} Stream close`)); stream.on('error', (err) => console.error(prefix, err)); stream.on('data', (data) => { console.log(`${prefix} Received: ${data}`); stream.close(); stream.end(); }); stream.write('"Hello world" from ' + prefix); } });
const net = require('net'); const { Server } = require('yamux-js'); const server = net.createServer((socket) => { console.log('Connected on port', socket.remotePort); const yamuxServer = new Server( (stream) => { stream.on('data', (data) => { console.log(`Received: ${data}`); stream.write('Server acknowledged: ' + data); }); stream.on('end', () => { console.log('Ending stream'); }); stream.on('close', () => { console.log('closed stream'); }); stream.on('error', (err) => console.error('Server stream error', err)); }, { enableKeepAlive: false, } ); socket.pipe(yamuxServer).pipe(socket); }); server.listen(3500);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
client
server
The text was updated successfully, but these errors were encountered: