The TCP and UDP bindings can be configured in the files services/tcp.cfg and services/udp.cfg, respectively. Note that the parameters set in these files will be common for all the TCP connections of this binding, both client and server connections. It is thus not possible to have different postambles for two distinct endpoints.
Note: This is optional for the configuration and not necessary for receiving data. Item-definitions are enough for receiving data. There's a bug in the binding that requires at least one udp configuration to be defined or the binding will not send UDP messages.
<command> is the openHAB command. <command>: can be omitted or have the value '*'. Omit the command if using generic mapping via transformations, or if no mapping is needed.
When the item receives a command it will send that data to the remote party. When data is received on the TCP connection, the item will get its state updated with a postUpdate. This is identical for incoming and outgoing directions. The direction just says who connects to whom (client/server); data can be sent and received from either.
Here are some examples of valid binding configuration strings.
Connect to a remote server and send any commands received. Both of the following are equivalent.
The TCP Binding will open a port to remote host 10.0.0.4:7000. Any commands received on the item will be sent to the remote with pre and postfix specified by preamble and postamble. The Item will get postUpdate on any data received from the remote via the TCP connection. The data can be mapped via rules to virtual items such as MyVirtualLyngdorfPowerSwitch.
The TCP binding may exhaust the memory and/or use up the CPU by trying to rebind connections. (GitHub issue 2706) .
An alternative solution to using the TCP Binding may be to use MQTT. See JGluch's example on the community forum.