var dgram = require(‘dgram’);
var socket = dgram.createSocket(‘udp4’);
socket.on(‘message’, function (message, remote) {
//显示server发回的消息
console.log(‘server ip:’ + remote.address + ‘, port:’ + remote.port +’, message:’ + message);
});
//监听端口
socket.bind(33333);
//发送消息
function send(server){
var message = new Buffer(“心花路放”);
socket.send(message, 0, message.length, 6881, server, function(){
//1秒后再次发送
setTimeout(function(){
send(server);
}, 1000);
});
};
send(“127.0.0.1”);
为什么没有爬到任何东西出来?