Child pages
  • udp

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{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=ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637}{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:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_des|text=|trigger=button}{sub-section}{sub-section:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_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:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_ret|text=|trigger=button}{sub-section}{sub-section:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_ret|trigger=none|class=sIndent}[JSPacket]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_see|text=|trigger=button}{sub-section}{sub-section:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_see|text=|trigger=button}{sub-section}{sub-section:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_sam|text=|trigger=button}{sub-section}{sub-section:ACDC277EBE1CACBA-4889CABE-45B7417A-8336B587-007F334D531A316EBCCD9637_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=0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474}{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:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_des|text=|trigger=button}{sub-section}{sub-section:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_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:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_ret|text=|trigger=button}{sub-section}{sub-section:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_ret|trigger=none|class=sIndent}[JSPacket]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_see|text=|trigger=button}{sub-section}{sub-section:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_see|text=|trigger=button}{sub-section}{sub-section:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_sam|text=|trigger=button}{sub-section}{sub-section:0A801F688F6ABC29-CB5FA33C-445D42E0-9C53B977-B6FDCC27C0588500B58BD474_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=767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55}{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:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_des|text=|trigger=button}{sub-section}{sub-section:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_des|trigger=none|class=sIndent}Send a packet.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_prs|trigger=none}ip/host
packet
\[port\]
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_ret|text=|trigger=button}{sub-section}{sub-section:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_see|text=|trigger=button}{sub-section}{sub-section:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_see|text=|trigger=button}{sub-section}{sub-section:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_sam|text=|trigger=button}{sub-section}{sub-section:767297A558FCCE16-928F4C94-40094955-82ADB207-251962D20B440BC4C97E3F55_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=A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6}{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:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_des|text=|trigger=button}{sub-section}{sub-section:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_des|trigger=none|class=sIndent}Start a UDP socket for a port.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_prs|trigger=none}portnumber
methodToInvokeWhenPacketReceivedAndBufferIsEmpty
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_ret|text=|trigger=button}{sub-section}{sub-section:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_see|text=|trigger=button}{sub-section}{sub-section:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_see|text=|trigger=button}{sub-section}{sub-section:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_sam|text=|trigger=button}{sub-section}{sub-section:A6CE99A6AE26C3B7-FF79DE4A-4FD84360-BAAEB10D-D75A04F910290B09E95703D6_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=282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54}{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:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_des|text=|trigger=button}{sub-section}{sub-section:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_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:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_ret|text=|trigger=button}{sub-section}{sub-section:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_see|text=|trigger=button}{sub-section}{sub-section:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_see|text=|trigger=button}{sub-section}{sub-section:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_sam|text=|trigger=button}{sub-section}{sub-section:282E785C5F167230-EF7F6AE5-41AB4D72-9A51857B-ADF7568A0B1596BB1ED80C54_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=0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE}{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:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_des|text=|trigger=button}{sub-section}{sub-section:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_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:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_prs|trigger=none}packet
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_ret|text=|trigger=button}{sub-section}{sub-section:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_see|text=|trigger=button}{sub-section}{sub-section:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_see|text=|trigger=button}{sub-section}{sub-section:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_sam|text=|trigger=button}{sub-section}{sub-section:0A5174673DC40308-221A0D93-48054789-988B8412-D82AF00E05D16FE3D68EB8EE_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}