if (!plugins.udp.startSocket('5555', packetReceived)) {
application.output('Failed to start socket.');
} else {
var packet = plugins.udp.createNewPacket();
packet.writeUTF('hello world!');
plugins.udp.sendPacket('localhost', packet, 1234);
packet = plugins.udp.createNewPacket();
packet.writeByte(0xFF);
packet.writeShort(10001);
packet.writeInt(2000000001);
plugins.udp.sendPacket('localhost', packet, 1234);
var imgBytes = plugins.file.readFile('logo.jpg', 1024);
packet = plugins.udp.createNewPacket();
packet.writeBytes(imgBytes);
plugins.udp.sendPacket('localhost', packet, 1234);
plugins.udp.stopSocket();
} |