{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=ACDC277E-4889-45B7-8336-007F334D531A}{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:ACDC277E-4889-45B7-8336-007F334D531A_des|text=|trigger=button}{sub-section}{sub-section:ACDC277E-4889-45B7-8336-007F334D531A_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:ACDC277E-4889-45B7-8336-007F334D531A_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:ACDC277E-4889-45B7-8336-007F334D531A_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:ACDC277E-4889-45B7-8336-007F334D531A_ret|text=|trigger=button}{sub-section}{sub-section:ACDC277E-4889-45B7-8336-007F334D531A_ret|trigger=none|class=sIndent}[JSPacket]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:ACDC277E-4889-45B7-8336-007F334D531A_see|text=|trigger=button}{sub-section}{sub-section:ACDC277E-4889-45B7-8336-007F334D531A_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:ACDC277E-4889-45B7-8336-007F334D531A_see|text=|trigger=button}{sub-section}{sub-section:ACDC277E-4889-45B7-8336-007F334D531A_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:ACDC277E-4889-45B7-8336-007F334D531A_sam|text=|trigger=button}{sub-section}{sub-section:ACDC277E-4889-45B7-8336-007F334D531A_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=0A801F68-CB5F-445D-9C53-B6FDCC27C058}{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:0A801F68-CB5F-445D-9C53-B6FDCC27C058_des|text=|trigger=button}{sub-section}{sub-section:0A801F68-CB5F-445D-9C53-B6FDCC27C058_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:0A801F68-CB5F-445D-9C53-B6FDCC27C058_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:0A801F68-CB5F-445D-9C53-B6FDCC27C058_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:0A801F68-CB5F-445D-9C53-B6FDCC27C058_ret|text=|trigger=button}{sub-section}{sub-section:0A801F68-CB5F-445D-9C53-B6FDCC27C058_ret|trigger=none|class=sIndent}[JSPacket]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:0A801F68-CB5F-445D-9C53-B6FDCC27C058_see|text=|trigger=button}{sub-section}{sub-section:0A801F68-CB5F-445D-9C53-B6FDCC27C058_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:0A801F68-CB5F-445D-9C53-B6FDCC27C058_see|text=|trigger=button}{sub-section}{sub-section:0A801F68-CB5F-445D-9C53-B6FDCC27C058_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:0A801F68-CB5F-445D-9C53-B6FDCC27C058_sam|text=|trigger=button}{sub-section}{sub-section:0A801F68-CB5F-445D-9C53-B6FDCC27C058_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=767297A5-928F-4009-82AD-251962D20B44}{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:767297A5-928F-4009-82AD-251962D20B44_des|text=|trigger=button}{sub-section}{sub-section:767297A5-928F-4009-82AD-251962D20B44_des|trigger=none|class=sIndent}Send a packet.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:767297A5-928F-4009-82AD-251962D20B44_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:767297A5-928F-4009-82AD-251962D20B44_prs|trigger=none}ip/host
packet
\[port\]
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:767297A5-928F-4009-82AD-251962D20B44_ret|text=|trigger=button}{sub-section}{sub-section:767297A5-928F-4009-82AD-251962D20B44_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:767297A5-928F-4009-82AD-251962D20B44_see|text=|trigger=button}{sub-section}{sub-section:767297A5-928F-4009-82AD-251962D20B44_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:767297A5-928F-4009-82AD-251962D20B44_see|text=|trigger=button}{sub-section}{sub-section:767297A5-928F-4009-82AD-251962D20B44_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:767297A5-928F-4009-82AD-251962D20B44_sam|text=|trigger=button}{sub-section}{sub-section:767297A5-928F-4009-82AD-251962D20B44_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=A6CE99A6-FF79-4FD8-BAAE-D75A04F91029}{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:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_des|text=|trigger=button}{sub-section}{sub-section:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_des|trigger=none|class=sIndent}Start a UDP socket for a port.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_prs|trigger=none}portnumber
methodToInvokeWhenPacketReceivedAndBufferIsEmpty
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_ret|text=|trigger=button}{sub-section}{sub-section:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_see|text=|trigger=button}{sub-section}{sub-section:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_see|text=|trigger=button}{sub-section}{sub-section:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_sam|text=|trigger=button}{sub-section}{sub-section:A6CE99A6-FF79-4FD8-BAAE-D75A04F91029_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=282E785C-EF7F-41AB-9A51-ADF7568A0B15}{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:282E785C-EF7F-41AB-9A51-ADF7568A0B15_des|text=|trigger=button}{sub-section}{sub-section:282E785C-EF7F-41AB-9A51-ADF7568A0B15_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:282E785C-EF7F-41AB-9A51-ADF7568A0B15_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:282E785C-EF7F-41AB-9A51-ADF7568A0B15_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:282E785C-EF7F-41AB-9A51-ADF7568A0B15_ret|text=|trigger=button}{sub-section}{sub-section:282E785C-EF7F-41AB-9A51-ADF7568A0B15_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:282E785C-EF7F-41AB-9A51-ADF7568A0B15_see|text=|trigger=button}{sub-section}{sub-section:282E785C-EF7F-41AB-9A51-ADF7568A0B15_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:282E785C-EF7F-41AB-9A51-ADF7568A0B15_see|text=|trigger=button}{sub-section}{sub-section:282E785C-EF7F-41AB-9A51-ADF7568A0B15_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:282E785C-EF7F-41AB-9A51-ADF7568A0B15_sam|text=|trigger=button}{sub-section}{sub-section:282E785C-EF7F-41AB-9A51-ADF7568A0B15_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=0A517467-221A-4805-988B-D82AF00E05D1}{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:0A517467-221A-4805-988B-D82AF00E05D1_des|text=|trigger=button}{sub-section}{sub-section:0A517467-221A-4805-988B-D82AF00E05D1_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:0A517467-221A-4805-988B-D82AF00E05D1_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:0A517467-221A-4805-988B-D82AF00E05D1_prs|trigger=none}packet
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:0A517467-221A-4805-988B-D82AF00E05D1_ret|text=|trigger=button}{sub-section}{sub-section:0A517467-221A-4805-988B-D82AF00E05D1_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:0A517467-221A-4805-988B-D82AF00E05D1_see|text=|trigger=button}{sub-section}{sub-section:0A517467-221A-4805-988B-D82AF00E05D1_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:0A517467-221A-4805-988B-D82AF00E05D1_see|text=|trigger=button}{sub-section}{sub-section:0A517467-221A-4805-988B-D82AF00E05D1_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:0A517467-221A-4805-988B-D82AF00E05D1_sam|text=|trigger=button}{sub-section}{sub-section:0A517467-221A-4805-988B-D82AF00E05D1_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}