Table Row (tr) |
---|
| Table Head (th) |
---|
| Method Details |
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
getByteArray |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| byte[] |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| getByteArray |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns the content of the package into a byte array. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns byte[] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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;
}
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| String |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| getHost |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns the name of the host that sent the packet. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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;
}
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Number |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| getLength |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns the length of the packet in bytes. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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;
}
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Number |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| getPort |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns the port where the packet originated from. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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;
}
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Number |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| readByte |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Reads an 8 bits byte value from the packet, starting from the current index. Advances the index with one position. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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;
}
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Number |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| readInt |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Reads a 32 bits int value from the packet, starting from the current index. Advances the index with 4 positions. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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;
}
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Number |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| readShort |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Reads a 32 bits short value from the packet, starting from the current index. Advances the index with 2 positions. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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;
}
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| String |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| readUTF |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Reads a UTF string from the packet, starting from the current index. If an argument is specified, then it represents the length of the string to read. If no argument is specified, then first a 32 bits int is read from the packet and that will be the length of the string. Advances the index with a number of positions that depends on the length of the read string. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters [length] |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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;
}
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| void |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| writeByte |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Writes one byte into the packet, at the current index. The index is advanced with one position. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters number |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns void |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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();
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
writeBytes |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| void |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| writeBytes |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Writes an array of bytes into the packet, at the current index. The index is advanced with a number of positions equal to the length of the written array. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters array |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns void |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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();
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| void |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| writeInt |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Writes a 32 bits int into the packet, at the current index. The index is advances with 4 positions. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters number |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns void |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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();
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
writeShort |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| void |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| writeShort |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Writes a 16 bits short value into the packet, at the current index. The index is advances with 2 positions. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters number |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Returns void |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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();
}
|
|
|
|
|
Table Body (tbody) |
---|
| Table Row (tr) |
---|
| Table Cell (td) |
---|
Span |
---|
style | float: left; margin-right: 5px; |
---|
| Number |
Span |
---|
style | float: left; font-weight: bold; |
---|
id | iets |
---|
| writeUTF |
|
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Writes an UTF encoded string into the packet, at the current index. First the length of the string is written on 4 bytes, then the string is written. The index is advanced with a number of positions equal to the length of the string plus 4. |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Parameters string |
|
Table Row (tr) |
---|
| Table Cell (td) |
---|
Sample
Div |
---|
| Code Block |
---|
|
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();
}
|
|
|
|
|
|