DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR
{column:width=80px|padding=0px}{column}{column}{column}
Property Summary
{column:width=80px|padding=0px}{column}{column}{column}
Method Summary
byte[]
getByteArray()
Returns the content of the package into a byte array.
void
writeByte(number)
Writes one byte into the packet, at the current index.
void
writeBytes(bytes)
Writes an array of bytes into the packet, at the current index.
void
writeInt(number)
Writes a 32 bits int into the packet, at the current index.
void
writeShort(number)
Writes a 16 bits short value into the packet, at the current index.
{column:width=100%|padding=0px}{column}
Property Details
Sample
var packet; while (packet = plugins.udp.getReceivedPacket()) { application.output('packet received from ' + packet.getHost() + ':' + packet.getPort()); if (packet.getLength() > 0) { application.output('an int is: ' + packet.readInt()); application.output('moved to index: ' + packet.index); application.output('a short is: ' + packet.readShort()); application.output('moved to index: ' + packet.index); application.output('a byte is: ' + packet.readByte()); application.output('moved to index: ' + packet.index); application.output('a byte is: ' + packet.readByte()); application.output('moved to index: ' + packet.index); } else { application.output('end of communication.'); break; } }
{column:width=100%|padding=0px}{column}
Method Details
byte[]
getByteArray
()
Returns
byte[]
Sample
var packet; while (packet = plugins.udp.getReceivedPacket()) { application.output('packet received from ' + packet.getHost() + ':' + packet.getPort()); if (packet.getLength() > 0) { var bytes = packet.getByteArray(); application.output('received a packet of length: ' + bytes.length); for (var i=0; i<bytes.length; i++) application.output(bytes[i]); } else { application.output('end of communication.'); break; } }
getHost
()
Sample
var packet; while (packet = plugins.udp.getReceivedPacket()) { application.output('packet received from ' + packet.getHost() + ':' + packet.getPort()); if (packet.getLength() > 0) { application.output('message is: ' + packet.readUTF()); } else { application.output('end of communication.'); break; } }
getLength
()
Sample
var packet; while (packet = plugins.udp.getReceivedPacket()) { application.output('packet received from ' + packet.getHost() + ':' + packet.getPort()); if (packet.getLength() > 0) { application.output('message is: ' + packet.readUTF()); } else { application.output('end of communication.'); break; } }
getPort
()
Sample
var packet; while (packet = plugins.udp.getReceivedPacket()) { application.output('packet received from ' + packet.getHost() + ':' + packet.getPort()); if (packet.getLength() > 0) { application.output('message is: ' + packet.readUTF()); } else { application.output('end of communication.'); break; } }
readByte
()
Sample
var packet; while (packet = plugins.udp.getReceivedPacket()) { application.output('packet received from ' + packet.getHost() + ':' + packet.getPort()); if (packet.getLength() > 0) { application.output('an int is: ' + packet.readInt()); application.output('moved to index: ' + packet.index); application.output('a short is: ' + packet.readShort()); application.output('moved to index: ' + packet.index); application.output('a byte is: ' + packet.readByte()); application.output('moved to index: ' + packet.index); application.output('a byte is: ' + packet.readByte()); application.output('moved to index: ' + packet.index); } else { application.output('end of communication.'); break; } }
readInt
()
Sample
var packet; while (packet = plugins.udp.getReceivedPacket()) { application.output('packet received from ' + packet.getHost() + ':' + packet.getPort()); if (packet.getLength() > 0) { application.output('an int is: ' + packet.readInt()); application.output('moved to index: ' + packet.index); application.output('a short is: ' + packet.readShort()); application.output('moved to index: ' + packet.index); application.output('a byte is: ' + packet.readByte()); application.output('moved to index: ' + packet.index); application.output('a byte is: ' + packet.readByte()); application.output('moved to index: ' + packet.index); } else { application.output('end of communication.'); break; } }
readShort
()
Sample
var packet; while (packet = plugins.udp.getReceivedPacket()) { application.output('packet received from ' + packet.getHost() + ':' + packet.getPort()); if (packet.getLength() > 0) { application.output('an int is: ' + packet.readInt()); application.output('moved to index: ' + packet.index); application.output('a short is: ' + packet.readShort()); application.output('moved to index: ' + packet.index); application.output('a byte is: ' + packet.readByte()); application.output('moved to index: ' + packet.index); application.output('a byte is: ' + packet.readByte()); application.output('moved to index: ' + packet.index); } else { application.output('end of communication.'); break; } }
readUTF
()
Sample
var packet; while (packet = plugins.udp.getReceivedPacket()) { application.output('packet received from ' + packet.getHost() + ':' + packet.getPort()); if (packet.getLength() > 0) { application.output('message is: ' + packet.readUTF()); } else { application.output('end of communication.'); break; } }
readUTF
(length)
Sample
var packet; while (packet = plugins.udp.getReceivedPacket()) { application.output('packet received from ' + packet.getHost() + ':' + packet.getPort()); if (packet.getLength() > 0) { application.output('message is: ' + packet.readUTF()); } else { application.output('end of communication.'); break; } }
void
writeByte
(number)
Returns
void
Sample
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(); }
void
writeBytes
(bytes)
Parameters
{byte[]} bytes
Returns
void
Sample
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(); }
void
writeInt
(number)
Returns
void
Sample
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(); }
void
writeShort
(number)
Returns
void
Sample
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(); }
writeUTF
(string)
Sample
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(); }