{hidden}
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING.
		THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURCE{hidden}
{sub-section:description|text=}{sub-section}\\ 

{table:class=servoy sReturnTypes}{tr:style=height: 30px;}{th}Return Types{th}{tr}{tr}{td}{span:class=sWordList}[JSPacket]{span}{td}{tr}{table}\\ 

{table:class=servoy sSummery}{colgroup}{column:width=80px}{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 recieve buffer, read buffer until empty (null is returned).{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#sendPacket]\(ip/host, packet, port)
Send a packet.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#startSocket]\(portnumber, methodToInvokeWhenPacketReceivedAndBufferIsEmpty)
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:class=servoy sDetail}{colgroup}{column:width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=6962A55B-C624-4031-9123-57F697ABDDD9}{tr:id=name}{td}h6.createNewPacket{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSPacket]{span}{span:id=iets|style=float: left; font-weight: bold;}createNewPacket{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_des|text=|trigger=button}{sub-section}{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_des|trigger=none|class=sIndent}Create a new empty packet.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_ret|text=|trigger=button}{sub-section}{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_ret|trigger=none|class=sIndent}[JSPacket]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_see|text=|trigger=button}{sub-section}{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_see|text=|trigger=button}{sub-section}{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_sam|text=|trigger=button}{sub-section}{sub-section:6962A55B-C624-4031-9123-57F697ABDDD9_sam|class=sIndent|trigger=none}{code:language=javascript}
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}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=405EBD91-B312-477E-9741-1355EAA6A73D}{tr:id=name}{td}h6.getReceivedPacket{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSPacket]{span}{span:id=iets|style=float: left; font-weight: bold;}getReceivedPacket{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_des|text=|trigger=button}{sub-section}{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_des|trigger=none|class=sIndent}Get a packet from recieve buffer, read buffer until empty (null is returned).{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_ret|text=|trigger=button}{sub-section}{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_ret|trigger=none|class=sIndent}[JSPacket]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_see|text=|trigger=button}{sub-section}{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_see|text=|trigger=button}{sub-section}{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_sam|text=|trigger=button}{sub-section}{sub-section:405EBD91-B312-477E-9741-1355EAA6A73D_sam|class=sIndent|trigger=none}{code:language=javascript}
var packet = null
while( ( packet = plugins.udp.getReceivedPacket() ) != null)
{
	var text = packet.readUTF()
	var count = packet.readInt()
}
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=D3B25E08-7542-44FA-86D0-C6E5506782B3}{tr:id=name}{td}h6.sendPacket{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}sendPacket{span}{span:id=iets|style=float: left;}\(ip/host, packet, port){span}{td}{tr}{tr:id=des}{td}{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_des|text=|trigger=button}{sub-section}{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_des|trigger=none|class=sIndent}Send a packet.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_prs|trigger=none}ip/host
packet
\[port\]
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_ret|text=|trigger=button}{sub-section}{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_see|text=|trigger=button}{sub-section}{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_see|text=|trigger=button}{sub-section}{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_sam|text=|trigger=button}{sub-section}{sub-section:D3B25E08-7542-44FA-86D0-C6E5506782B3_sam|class=sIndent|trigger=none}{code:language=javascript}
var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')
plugins.udp.sendPacket('10.0.0.1',packet)
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99}{tr:id=name}{td}h6.startSocket{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}startSocket{span}{span:id=iets|style=float: left;}\(portnumber, methodToInvokeWhenPacketReceivedAndBufferIsEmpty){span}{td}{tr}{tr:id=des}{td}{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_des|text=|trigger=button}{sub-section}{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_des|trigger=none|class=sIndent}Start a UDP socket for a port.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_prs|trigger=none}portnumber
methodToInvokeWhenPacketReceivedAndBufferIsEmpty
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_ret|text=|trigger=button}{sub-section}{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_see|text=|trigger=button}{sub-section}{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_see|text=|trigger=button}{sub-section}{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_sam|text=|trigger=button}{sub-section}{sub-section:875DBCC8-FAB6-415F-9E8B-9C0AC40C7A99_sam|class=sIndent|trigger=none}{code:language=javascript}
plugins.udp.startSocket(1234,my_packet_process_method)
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=E7D517D4-2148-4EAA-AA6D-EB88CD42909A}{tr:id=name}{td}h6.stopSocket{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}stopSocket{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_des|text=|trigger=button}{sub-section}{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_des|trigger=none|class=sIndent}Stop the UDP socket for a port.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_ret|text=|trigger=button}{sub-section}{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_see|text=|trigger=button}{sub-section}{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_see|text=|trigger=button}{sub-section}{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_sam|text=|trigger=button}{sub-section}{sub-section:E7D517D4-2148-4EAA-AA6D-EB88CD42909A_sam|class=sIndent|trigger=none}{code:language=javascript}
plugins.udp.stopSocket()
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097}{tr:id=name}{td}h6.testPacket{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}testPacket{span}{span:id=iets|style=float: left;}\(packet){span}{td}{tr}{tr:id=des}{td}{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_des|text=|trigger=button}{sub-section}{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_des|trigger=none|class=sIndent}Put a test packet in the receive buffer to test your method call and getReceivedPacket.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_prs|trigger=none}packet
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_ret|text=|trigger=button}{sub-section}{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_see|text=|trigger=button}{sub-section}{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_see|text=|trigger=button}{sub-section}{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_sam|text=|trigger=button}{sub-section}{sub-section:DD20FD1F-74F2-4A27-B1CD-95C1FCFDE097_sam|class=sIndent|trigger=none}{code:language=javascript}
var packet = plugins.udp.createNewPacket()
packet.writeUTF('hello world!')
plugins.udp.testPacket(packet)
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}