Child pages
  • udp

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
{div:style=}
Wiki Markup
Div
styledisplay:none

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.\\ \\ Enter additional information related to this 'class' inside the \{div} macro with 'id=description'{div} {div:id=description}{div}\\ {table:id=|class=servoy sReturnTypes}{tr:style=height: 30px;}{th}Return Types{th}{tr}{tr}{td}{span:class=sWordList}[JSPacket]{span}{td}{tr}{table}\\ {table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}[JSPacket]{td}{td}[#createNewPacket]\() Create a new empty packet.{td}{tr}{tbody}{tbody}{tr}{td}[JSPacket]{td}{td}[#getReceivedPacket]\() Get a packet from receive buffer, read buffer until empty (null is returned).{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#sendPacket]\(destIpOrHostname, packet) Send a packet.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#sendPacket]\(destIpOrHostname, packet, port) Send a packet on another port.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#startSocket]\(port_number,

GENERATOR.

Div
iddescription



HTML Table
id
classservoy sReturnTypes
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Return Types
Table Row (tr)
Table Cell (td)
Span
classsWordList
JSPacket



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Row (tr)
Table Cell (td)
JSPacket
Table Cell (td)
createNewPacket()
Create a new empty packet.
Table Row (tr)
Table Cell (td)
JSPacket
Table Cell (td)
getReceivedPacket()
Get a packet from receive buffer, read buffer until empty (null is returned).
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
sendPacket(destIpOrHostname, packet)
Send a packet.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
sendPacket(destIpOrHostname, packet, port)
Send a packet on another port.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
startSocket(port_number, method_to_call_when_packet_received_and_buffer_is_empty)

Start
a
UDP
socket
for
a
port.
{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#stopSocket]\() Stop the UDP socket for a port.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#testPacket]\(packet) Put a test packet in the receive buffer to test your method call and getReceivedPacket.{td}{tr}{tbody}{table}\\ {table:id=function|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=createNewPacket}{tr:id=name}{td}h6.createNewPacket{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[JSPacket]{span}{span:style=font-weight: bold;}createNewPacket{span}{span}\(){span}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[JSPacket]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
Table Cell (td)
void
Table Cell (td)
stopSocket()
Stop the UDP socket for a port.
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)
testPacket(packet)
Put a test packet in the receive buffer to test your method call and getReceivedPacket.



HTML Table
idfunction
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
idcreateNewPacket
Table Row (tr)
idname
Table Cell (td)

createNewPacket

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSPacket
Span
stylefont-weight: bold;
createNewPacket
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Create a new empty packet.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
JSPacket
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')//writes UTF
packet.writeInt(12348293)//writes 4 bytes
packet.writeShort(14823)//writes 2 bytes
packet.writeByte(123)//writes 1 byte
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getReceivedPacket}{tr:id=name}{td}h6.getReceivedPacket{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[JSPacket]{span}{span:style=font-weight: bold;}getReceivedPacket{span}{span}\(){span}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[JSPacket]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetReceivedPacket
Table Row (tr)
idname
Table Cell (td)

getReceivedPacket

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSPacket
Span
stylefont-weight: bold;
getReceivedPacket
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get a packet from receive buffer, read buffer until empty (null is returned).
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
JSPacket
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var packet = null
while( ( packet = plugins.udp.getReceivedPacket() ) != null)
{
	var text = packet.readUTF()
	var count = packet.readInt()
}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsendPacket-String_JSPacket
}{
Table Row (tr)
:
id
=
name
}{td}h6.sendPacket{td}{tr}{tr:id=sig}{td}{span:style=
Table Cell (td)

sendPacket

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right:
5px;
}[
Boolean
]{span}{span:style=
Span
stylefont-weight:
bold;
}
sendPacket
{span}{span}\
Span
(destIpOrHostname,
packet)
{span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} destIpOrHostname -- the ip of the destination or the hostname \{[JSPacket]} packet -- the JSPacket to send {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Send a packet.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} destIpOrHostname - the ip of the destination or the hostname
{JSPacket} packet - the JSPacket to send
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')
plugins.udp.sendPacket('10.0.0.1',packet)
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsendPacket-String_JSPacket_Number
}{
Table Row (tr)
:
id
=
name
}{td}h6.sendPacket{td}{tr}{tr:id=sig}{td}{span:style=
Table Cell (td)

sendPacket

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right:
5px;
}[
Boolean
]{span}{span:style=
Span
stylefont-weight:
bold;
}
sendPacket
{span}{span}\
Span
(destIpOrHostname,
packet,
port)
{span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[String]} destIpOrHostname -- the ip of the destination or the hostname \{[JSPacket]} packet -- the JSPacket to send \{[Number]} port -- the port on which to send the packet {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Send a packet on another port.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{String} destIpOrHostname - the ip of the destination or the hostname
{JSPacket} packet - the JSPacket to send
{Number} port - the port on which to send the packet
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')
plugins.udp.sendPacket('10.0.0.1',packet, 4321)
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idstartSocket-Number_Object
}{
Table Row (tr)
:
id
=
name
}{td}h6.startSocket{td}{tr}{tr:id=sig}{td}{span:style=
Table Cell (td)

startSocket

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right:
5px;
}[
Boolean
]{span}{span:style=
Span
stylefont-weight:
bold;
}
startSocket
{span}{span}\
Span
(port_number,
method_to_call_when_packet_received_and_buffer_is_empty)
{span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[Number]} port_number -- the local port that this UDP socket will bind to. \{[Object]}
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Start a UDP socket for a port.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Number} port_number - the local port that this UDP socket will bind to.
{Object} method_to_call_when_packet_received_and_buffer_is_empty
-
-
when
the
socket
receives
one
or
more
packages,
it
calls
this
method
once.

The
method
will
no
longer
be
called
even
if
new
packages
are
received
\
-
until
a
call
to
UDPProvider#js
\
_getReceivedPacket()
returns
null.
So
you
should

consume
all
available
packets
before
you
expect
this
method
to
be
called
again.
{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
plugins.udp.startSocket(1234,my_packet_process_method)
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=stopSocket}{tr:id=name}{td}h6.stopSocket{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}void{span}{span:style=font-weight: bold;}stopSocket{span}{span}\(){span}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}void{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idstopSocket
Table Row (tr)
idname
Table Cell (td)

stopSocket

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
void
Span
stylefont-weight: bold;
stopSocket
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Stop the UDP socket for a port.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
void
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
plugins.udp.stopSocket()
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=testPacket-JSPacket}{tr:id=name}{td}h6.testPacket{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[Boolean]{span}{span:style=font-weight: bold;}testPacket{span}{span}\(packet){span}{td}{tr}{tr:id=prs}{td}*Parameters*\\{div:class=sIndent}\{[JSPacket]} packet {div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Boolean]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idtestPacket-JSPacket
Table Row (tr)
idname
Table Cell (td)

testPacket

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
testPacket
Span
(packet)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Put a test packet in the receive buffer to test your method call and getReceivedPacket.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{JSPacket} packet
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')
plugins.udp.testPacket(packet)
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}
Table Row (tr)
classlastDetailRow
Table Cell (td)