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=BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB}{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:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_des|text=|trigger=button}{sub-section}{sub-section:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_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:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_ret|text=|trigger=button}{sub-section}{sub-section:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_ret|trigger=none|class=sIndent}[JSPacket]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_see|text=|trigger=button}{sub-section}{sub-section:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_see|text=|trigger=button}{sub-section}{sub-section:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_sam|text=|trigger=button}{sub-section}{sub-section:BE1CACBAB6CC2238-CABE3FCD-417A4459-B587BC02-316EBCCD96378D3E7C435EBB_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=8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C}{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:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_des|text=|trigger=button}{sub-section}{sub-section:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_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:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_ret|text=|trigger=button}{sub-section}{sub-section:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_ret|trigger=none|class=sIndent}[JSPacket]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_see|text=|trigger=button}{sub-section}{sub-section:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_see|text=|trigger=button}{sub-section}{sub-section:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_sam|text=|trigger=button}{sub-section}{sub-section:8F6ABC29A80F40FB-A33CE493-42E0481F-B977B3B2-8500B58BD4749D863A3F972C_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=58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52}{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:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_des|text=|trigger=button}{sub-section}{sub-section:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_des|trigger=none|class=sIndent}Send a packet.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_prs|trigger=none}ip/host
packet
\[port\]
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_ret|text=|trigger=button}{sub-section}{sub-section:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_see|text=|trigger=button}{sub-section}{sub-section:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_see|text=|trigger=button}{sub-section}{sub-section:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_sam|text=|trigger=button}{sub-section}{sub-section:58FCCE16AB24C0E6-4C94A0D1-4955436A-B207A559-0BC4C97E3F55098B76691A52_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=AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73}{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:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_des|text=|trigger=button}{sub-section}{sub-section:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_des|trigger=none|class=sIndent}Start a UDP socket for a port.{sub-section}{td}{tr}{tr:id=prs}{td}*Parameters*\\{sub-section:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_prs|trigger=none}portnumber
methodToInvokeWhenPacketReceivedAndBufferIsEmpty
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_ret|text=|trigger=button}{sub-section}{sub-section:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_see|text=|trigger=button}{sub-section}{sub-section:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_see|text=|trigger=button}{sub-section}{sub-section:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_sam|text=|trigger=button}{sub-section}{sub-section:AE26C3B7F6E96458-DE4A6EC7-436047FE-B10D9094-0B09E95703D60D2E895C0F73_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=5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89}{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:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_des|text=|trigger=button}{sub-section}{sub-section:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_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:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_ret|text=|trigger=button}{sub-section}{sub-section:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_ret|trigger=none|class=sIndent}void{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_see|text=|trigger=button}{sub-section}{sub-section:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_see|text=|trigger=button}{sub-section}{sub-section:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_sam|text=|trigger=button}{sub-section}{sub-section:5F1672305CF9C24B-6AE585AA-4D724947-857B9A84-96BB1ED80C540E697795DE89_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=3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66}{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:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_des|text=|trigger=button}{sub-section}{sub-section:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_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:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_prs|trigger=none}packet
{sub-section}{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{sub-section:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_ret|text=|trigger=button}{sub-section}{sub-section:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_ret|trigger=none|class=sIndent}[Boolean]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_see|text=|trigger=button}{sub-section}{sub-section:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_see|text=|trigger=button}{sub-section}{sub-section:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_sam|text=|trigger=button}{sub-section}{sub-section:3DC40308D74729F1-0D9357E7-478944D6-8412ADA9-6FE3D68EB8EE36F117DD7A66_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}