UNDER CONSTRUCTION |
UDP
Overview
UDP is a Dyalog cover function for Asynchronous UDP/IP Communication using the .Net UdpClient object. It is using the methods WriteAsync and ReadAsync available with .Net 4.5 for asynchronous communication that will not block the calling thread during the communication process. It is used to requests data from an Internet resource using UDP (User Datagram Protocol) over IP (Internet Protocol) like for home automation, data acquisition and process control.
An application using UDP prepares a packet and sends it to the receiver's address without first checking to see if the receiver is ready to receive a packet. If the receiving end is not ready to receive a packet, the packet is lost. In practice, UDP is quite reliable as long as the receiving socket is active and is processing data as quickly as it arrives. This is particularly the case when used on a private network. The application that is using UDP must be prepare to resend the data in case that it did not arrive to the receiving end.
Typical Usage
Since UDP is a connectionless protocol there is no need to connect before sending the bytes.
r ← {PortTimeOut}UDP(bytes ip port) ⍝ bytes = Bytes (as Numbers 0 to 255) to be Written to the Communication Port ⍝ ip = IP Address where to send the bytes in characters ('192.168.1.1') or numbers (192 168 1 1) ⍝ port = Port Number to send the bytes (0 - 65535) ⍝ PortTimeOut is the Time in milliseconds to Wait for a UdpClient that is not Active (Receiving Nothing). ⍝ If exceeded Windows Stop Waiting and returns the Control to the Calling Application. ⍝ The default value is 250 milliseconds. ⍝ r[1] = 1 for Success, 0 for Failure ⍝ r[2] = Response if Success, Literal Error if Failure
How to install UDP in your workspace
Download UDP.v1.0.txt
- Do a Select all (Ctrl+A) and a copy (Ctrl+C).
In your workspace execute )ed ⍟ UDP
- Paste (Ctrl+V) the text into the Dyalog editor
- Press Escape and ')save' your workspace
Version Information
Version 1.0 December 2016, Pierre Gilbert
Original author: |
Pierre Gilbert |
Responsible: |
|
Email: |
<apgil AT SPAMFREE videotron DOT ca> |