Created
April 19, 2018 18:34
-
-
Save emschwartz/f62e8c7bb9d3d0a82b756a2d7095de6f to your computer and use it in GitHub Desktop.
Socket test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const net = require('net') | |
const server = net.createServer((connection) => { | |
connection.on('close', () => console.log('server close')) | |
connection.on('end', () => console.log('server end')) | |
connection.on('error', () => console.log('server error')) | |
connection.on('finish', () => console.log('server finish')) | |
connection.on('data', (chunk) => console.log('server got data', chunk.length)) | |
//setTimeout(() => console.log('reading data', connection.read(1000)), 10) | |
//connection.write(Buffer.alloc(10000000)) | |
}) | |
server.listen(8124, () => { | |
const connection = net.createConnection(8124) | |
connection.on('connect', () => { | |
connection.write(Buffer.alloc(10000000)) | |
console.log('client wrote data') | |
connection.end() | |
console.log('client called end') | |
}) | |
connection.on('close', () => console.log('client close')) | |
connection.on('end', () => console.log('client end')) | |
connection.on('error', () => console.log('client error')) | |
connection.on('finish', () => console.log('client finish')) | |
//connection.on('data', (chunk) => console.log('client got data', chunk.length)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment