Created
July 16, 2016 15:51
-
-
Save uhyo/bad2e178f70188b5389f39d031e1737b to your computer and use it in GitHub Desktop.
tcp
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 PORT = 8080; | |
| const net = require('net'); | |
| const srv = net.createServer(sock=>{ | |
| console.log('New connection'); | |
| sock.on('data', buf=>{ | |
| console.log('---------- data start ----------'); | |
| console.log(buf.toString()); | |
| console.log('---------- data end ------------'); | |
| }); | |
| sock.on('error', e=> console.log(e)); | |
| sock.on('close', ()=> console.log('Socket closed')); | |
| }); | |
| srv.listen(PORT, ()=>{ | |
| console.log('Server is listening on', srv.address()); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment