I use the nodejs listening terminal to send data to the designated port, the code is as follows. But the monitored data is a piece of garbled code, please give us a lot of advice!
var net = require("net");
//
var listenPort = 26123;
var server = net.createServer(function(socket){
// socket
console.log("connect: " +
socket.remoteAddress + ":" + socket.remotePort);
socket.setEncoding("binary");
//
socket.on("data",function(data){
console.log("UE send:" + data);
});
//
socket.on("error",function(exception){
console.log("socket error:" + exception);
socket.end();
});
socket.on("close",function(data){
console.log("client closed!");
});
}).listen(listenPort);
//
server.on("listening",function(){
console.log("server listening:" + server.address().port);
});
//
server.on("error",function(exception){
console.log("server error:" + exception);
});
< hr >
the 460113003132269 in the result is the IMSI number of my terminal, 101.132.155.126 json 26123 is the ip address and port I am listening to, and the rest of the information is garbled. I would like to ask you guys how to display these data correctly, such as serializing them into json format and so on.