Net
Talk to the network: download a web page or call a web service (HTTP GET), post data to one (HTTP POST), check whether the internet can be reached, and send UDP messages to other devices.
Where to find it: type Net. in a Python script, or open the ARCx API view of the script editor and expand Net
Commands
| Command | What it does |
|---|---|
| Net.HTTPGet | Downloads a web address with an HTTP GET and returns it as text. |
| Net.HTTPPost | Sends form data to a web address with an HTTP POST and returns the server's reply. |
| Net.IsInternetAvailable | Checks whether ARCx can reach the Synthiam website, as a test of the internet connection. |
| Net.SendUDP | Sends a single byte as one UDP packet to a computer or device on the network. |
Details
Net.HTTPGet
Downloads a web address with an HTTP GET and returns it as text. Waits up to 2 seconds, and raises an error if the server cannot be reached, answers with an error or takes too long.
Net.HTTPGet(url)
Net.HTTPGet(url, timeout)
| Value | Type | What it is |
|---|---|---|
url |
str | The web address, starting with http:// or https://. |
timeout |
int | Optional. How long to wait for the reply, in milliseconds. |
Gives back: str. The text of the server's reply.
Net.HTTPPost
Sends form data to a web address with an HTTP POST and returns the server's reply. Waits up to 2 seconds, and raises an error if the server cannot be reached, answers with an error or takes too long.
Net.HTTPPost(url, postData)
Net.HTTPPost(url, postData, timeout)
| Value | Type | What it is |
|---|---|---|
url |
str | The web address, starting with http:// or https://. |
postData |
str | The data to send, form encoded, such as name=Bob&age=5. |
timeout |
int | Optional. How long to wait for the reply, in milliseconds. |
Gives back: str. The text of the server's reply.
Net.IsInternetAvailable
Checks whether ARCx can reach the Synthiam website, as a test of the internet connection. Waits for the reply, up to 4 seconds by default.
Net.IsInternetAvailable()
Gives back: bool. Whether the internet can be reached.
Net.SendUDP
Sends a single byte as one UDP packet to a computer or device on the network. It does not wait for a reply or confirm that the packet arrived.
Net.SendUDP(hostname, port, b)
Net.SendUDP(hostname, port, byteArray)
| Value | Type | What it is |
|---|---|---|
hostname |
str | The name or IP address of the computer or device to send to. |
port |
int | The UDP port number on the receiving end. |
byteArray |
object | Only in some forms. A bytearray holding the bytes to send. |
b |
int | Only in some forms. The byte to send, 0 to 255. |
Net.SendUDP(hostname, port, b): Sends a single byte as one UDP packet to a computer or device on the network. It does not wait for a reply or confirm that the packet arrived.Net.SendUDP(hostname, port, byteArray): Sends bytes as one UDP packet to a computer or device on the network. It does not wait for a reply or confirm that the packet arrived.
Gives back: int. The number of bytes sent.