Connect SDK to Pandoras Box

Navigation:  Pandoras Box > SDK > Examples >

Connect SDK to Pandoras Box

prev main next

Navigation:  Pandoras Box > SDK > Examples >

Connect SDK to Pandoras Box

prev main next

Please wait. Due to its content this page might take a while to load...

Show/Hide hidden text

TCP versus UDP
The Pandoras Automation allows both, TCP and UDP connections. Both protocols allow sending data via a network connection. The ports that are used are 6211 for TCP and 6212 for UDP whilst the ports used for the TCP and UDP communication between a PB Master and PB Client are 1234 and 1235.

TCP has the advantage, that all packages are guaranteed to be delivered. To make that possible, TCP requires to send additional data, the so called acknowledge bits. The message sender asks the receiver for an acknowledge bit. If the receiver does not confirm, the message is send again. In addition TCP ensures the correct order of message packages. This is done by the network adapter; if packages are received in non-chronological order, it buffers the packages. The downside is, that the connection gets slower. The disadvantage of the acknowledging process is to be found when very large amounts of data is send as more network traffic is caused. Most sensors, for example send a lot of data, thus TCP would not be the protocol of choice. It is a different matter when you need to send "important" data and want to be sure that it arrives.
In short, decide for a TCP connection if the applications are connected in a stable network (by cable) and react to user interaction by sending a manageable amount of commands to PB Automation. When using TCP you can choose between automatic mode which will automatically reconnect or a "try once".

UDP is a better choice in scenarios where a lot of data is sent, or in case packages do not necessarily need to be acknowledged. In the UDP protocol the server does not know whether the clients received the messages, it rather sends the messages "blind". This way, UDP offers a faster response time for your application. The main disadvantage from a UDP protocol is that UDP packages are not as prioritized as TCP data. Thus each switch in the network may discard UDP data without further notice as soon as the network traffic reaches its limit.
In short, decide for a UDP connection if the application is allowed to get disconnected from the Master for short periods of time. Also, UDP is the better choice for applications that are updating values permanently, like in tracking systems or systems with permanent user interaction.

The following commands are needed to initialize the connection. The commands are listed with an example, assuming the Master system runs on a certain IP address and is set up with a certain domain number. The IP address can be found in the Asset tab of the PB software, the domain channel is a Pandoras Box internal number set up in the Configuration tab.

Initializing TCP
Make sure you configured (or disabled) your firewall to allow your application to communicate with Pandoras Box.
Initialize the connection to the Pandoras Box Master running at IP 10.0.0.1 with Domain number 0. The third parameter allows to choose between
- False: instantly try to connect once
- True: wait and connect as soon as possible
Setting "waitForConnection" to True also enables automatic reconnecting on connection loss.
Note: You can later on enable the "waitForConnection" feature by using AutoWaitForConnection() and disable it by using AutoStopWaitingForConnection()

hmtoggle_arrow1Visual Basic

hmtoggle_arrow1C#

Initializing UDP connections
Initialize the connection to Pandoras Box Master running at IP 10.0.0.1 with Domain number 0. Pandoras Automation will try to connect to Pandoras Box and verify the connection with a handshake.

hmtoggle_arrow1Visual Basic

hmtoggle_arrow1C#

Now that you are connected to Pandoras Box, you can start Sending Parameter Values.