Search
Start typing to search...

Using UDP and TCP in Aximmetry

Author:

Introduction

This document discusses how to communicate between different computers, devices, or software using UDP or TCP modules. You can communicate over the internet or in the local network or even on the same computer between different apps.
NOTE: Aximmetry has implementations of various protocols that use UDP or TCP. For example, if you want to receive or send OSC protocol through UDP then you should look up the OSC In-, and Output Setup documentation instead of using the modules in this documentation.

UDP or TCP, What is the Difference?

In general, UDP is used for real-time one-way communication where data loss will not cause an issue.
While TCP is a reliable connection at the cost of more delay and taking more bandwidth than UDP.

In the case of UDP, more than one computer can receive the UDP data when using multicast or broadcast.
While TCP can only be received by one computer. However, one computer can have TCP connections from multiple computers. And since TCP is a connection-based protocol, it can send back data to every connected computer.


In UDP, the maximum size of data that can be sent is limited by the IP packet size.
In the case of TCP, there is no data size limit because the Terminator can split your data, which can cause your data to be Received in separate frames.

UDP Sender and TCP Client

You can send UDP data using the UDP Sender module in the Flow Editor and send TCP data using the TCP Client module.

NOTE: If you want to receive this sent data on another computer in Aximmetry, then you can do so by using the UDP Receiver or TCP Server modules.
NOTE: Since TCP is a connection-based protocol, the module is called Client. While UDP is connectionless, hence the module is called Sender.

Input Pins

  • UDP Open and TCP Connect
    Connects to the target host. It must be turned on to send data.
  • Hostname
    You can give the targeted computer's system name or IP address as the Hostname when using the local network.
    You can use "localhost" as the Hostname to send data to the current computer. This can be useful if you want to communicate with other applications on the same computer using UDP or TCP. And it is also a good way to test out your Flow Editor logic using only one computer, more on it at Testing with Localhost.
  • Port
    A number between 1024 and 65536.
    NOTE: Only one running application should listen at the specific port on the receiving end.
  • Binary Mode
    Switches between sending text or byte (binary) data.
  • TCP Terminator and TCP Terminator Bytes
    Terminator indicates the end of a series of bytes or text that constitute a message.
    Terminator is not an inherent feature of the TCP protocol itself but is frequently used in conjunction with TCP. The Terminator pin should be set empty unless otherwise specified, or you are using the TCP to communicate between Aximmetry.
    When a terminator is specified, Aximmetry adds the terminator to the end of outgoing data. When receiving the data, Aximmetry waits for the arrival of the terminator character before writing out the data, excluding the terminator from the output. This implies that no data will be received if the incoming data does not include the terminator character. Additionally, it is important to ensure that the terminator is not included within your message content, as it will be removed from the output. Therefore, to avoid conflicts, your terminator should be unique and may consist of several characters for distinctiveness.
    NOTE: In the case of UDP, there is no terminator and the size of the data in a send is limited by the IP packet size.
  • Data and Data Bytes
    The text or bytes of the message that will be sent to the target host. To use Byte data instead of Text, turn on the Binary Mode pin.
  • Auto Send and Send
    Sending of the message can be performed in two ways. You can send it at a specific time by triggering it via the Send pin. Alternatively, you can turn On Auto Send, in this case, each time the Data value is changed it is sent automatically.

Output Pins

  • TCP Received and TCP Received Bytes
    Since TCP can send data back once the connection is established, the TCP Client has Received output pins just like the UDP Receiver and TCP Server.
    If you receive more than one message under a frame, then the message is put into a queue and the queue will be played out one by one in the following frames.
    When receiving byte data, these modules can convert the data: Bytes To Text, Bytes To Scalar, Bytes To Vector, and Bytes To Integer.
  • TCP Connected
    The TCP Client's Connected output pin is True when the module has established the connection with its target. If the target is a TCP Server module in another Aximmetry, then at the same time the TCP Server's Connections output pin will increase by one.

UDP Receiver and TCP Server

You can receive UDP data using the UDP Receiver module in the Flow Editor and receive TCP data using the TCP Server module.

For easy debugging when receiving data, you can easily expose the Received pin with the Text Peeker module:

NOTE: Since TCP is a connection-based protocol, the module is called Server. While UDP is connectionless, hence the module is called Receiver.

Input Pins

  • Listen
    It opens the port and starts listening for incoming data or connection.
  • Adapter
    The network adapter that will be used for the communication. If -any- is selected, then the module will listen on all network adapters.
  • Port
    A number between 1024 and 65536.
    NOTE: No other app should use the selected port on your computer.
  • Binary Mode
    Switches between receiving text or byte (binary) data.
  • TCP Terminator, TCP Terminator Bytes, Data, Auto Send, and Send
    These pins are the same as in the TCP Client module.
  • UDP Multicast Group
    Multicast enables UDP to be received by multiple different computers.
    The IP address of Multicast Group should be between 225.0.0.0 and 239.255.255.255.
    NOTE: It is possible to give an address from 224.0.0.0 but the range has reserved addresses by various standards.
    If you are using a UDP Sender module to send the UDP data, then you need to set its Hostname pin to the same address as Multicast Group.
    NOTE: Multicast won't work over the internet unless routers are configured accordingly.

Output Pins

  • Received and Received Bytes
    The data that is received through the port. To use Byte data instead of Text, turn on the Binary Mode pin.
    If you receive more than one message under a frame, then the message is put into a queue and the queue will be played out one by one in the following frames.
    When receiving byte data, these modules can convert the data: Bytes To Text, Bytes To Scalar, Bytes To Vector, and Bytes To Integer.
  • Listening
    The listening output pin turns True if the Listen pin is successfully turned on and the module starts listening for data packets on the port.
  • TCP Connections
    The amount of computers that established a connection with the TCP Server module.

Testing with Localhost

You can easily test your modules after the Received pin by adding a UDP Sender or TCP Client module and setting its Hostname to "localhost". The module will then send the data to your current computer. And you can receive this data in the same compound:

Structuring Complex Data

When using complex data, you can put the data into a Collection pin data type and convert them to text using a Collection To JSON or Collection To XML module. You can then connect the text to the Data pin of the module. When receiving such data, you can parse it into a collection using the JSON Text or XML Text module.
For example:

Article content

Loading
Close
Loading spinner icon
1/10