You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

23 lines
666 B

"use strict";
const { Controller } = require("egg");
class HomeController extends Controller {
async index() {
const { ctx } = this;
let array = ctx.request.body.hex.split(" ");
let hex_array = array.map((el) => parseInt(el, 16));
let uarray = new Uint8Array(hex_array);
let buf = Buffer.from(uarray);
const dgram = require("dgram");
const clientSocket = dgram.createSocket("udp4");
//监听指定地址以及端口
//第一个参数是发送数据,第二个参是位端口号,第三个参数为ip地址
clientSocket.send(buf, 80, "192.168.1.64");
// ctx.body = "发送";
}
}
module.exports = HomeController;