-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
27 lines (23 loc) · 721 Bytes
/
Copy pathserver.js
File metadata and controls
27 lines (23 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var net = require('net')
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
})
const prompt = require("prompt-sync")({ sigint: true });
server = net.createServer(socket => {
console.log('some client connected')
//socket.on('connection', x => console.log('some client connected'))
socket.write('dasfdag')
socket.on('data', Buffer => {
console.log(Buffer.toString())
const sc = prompt('wtc')
socket.write(sc)
})
socket.on('error', error => console.log(error))
socket.on('end', x => {
console.log('some client disconnected')
server.getConnections((x, y) => console.log(y))
})
}
)
server.listen(3000, '127.0.0.1')