Merge pull request #352 from yzqzy/main

feat: add nodejs client
This commit is contained in:
ttttupup 2024-02-06 20:15:06 +08:00 committed by GitHub
commit 3b5f191bf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,26 @@
const net = require('net')
const server = net.createServer(socket => {
console.log('New client connected')
let data = Buffer.from('')
socket.on('data', data => {
data = Buffer.concat([data, chunk])
console.log(`Received data: ${data}`)
})
socket.on('end', () => {
const decodedData = data.toString('utf8')
console.log(`Received data: ${decodedData}`)
})
socket.on('close', () => {
console.log('Client disconnected')
})
})
const port = 19099
server.listen(port, () => {
console.log(`Server listening on port ${port}`)
})