在下面的代码中,有什么方法可以简单地记录二进制数据而不转换为字符串?
var server = net.createServer(function(sock) {
console.log('CONNECTED: ' + sock.remoteAddress +':'+ sock.remotePort);
sock.on('data', function(data) {
console.log('DATA ' + sock.remoteAddress + ': ' + data);
sock.write('You said "' + data + '"');
});
sock.on('close', function(data) {
console.log('CLOSED: ' + sock.remoteAddress +' '+ sock.remotePort);
});
})
答案 0 :(得分:0)
尝试这样的代码
server.on('connection', function (socket) {
socket.on('data', function (bufferData) {
console.log(bufferData);
})
})