Send Simple Telnet Commands

I'm looking to control the iTach IP2CC relay device.
I can send simple text strings TCP commands like "setstate,1:1,<0|1>" to turn OFF/ON one of the relays.
For example, using netcat on a mac I can turn on relay 2 with:

nc -vc 192.168.0.18 4998
setstate,1:2,1

I only need to turn on/off (no status).
Is there a simple way to send Telnet commands like this using Hubitat?
Or would it require writing a custom driver?
I saw this: https://github.com/martinezmp3/TivoTeleneDriver/blob/master/Tivo-Telnet.groovy

But my programming skills are quite limited.

Saw the word Telnet, had this bookmarked...
Any help?

Thank you for the suggestion.
When I try the initial driver, setup a virtual device with ip and port #, click "Connect Telnet," the "statusMessage" throws up "receive error: Stream is closed"

It appears that connection still does work, as I can toggle the relays afterward. However, what is that error about?

Sorry, my skills are limited to sometimes remembering threads I've read.... :man_shrugging:
Let's see if @thebearmay has a minute to take a look. :wave:

I use this Telnet driver to send commands to my Russound AV receiver.

Message is simply what was returned as a status. Driver is about as simple, or raw, as they come, no fluff

https://docs2.hubitat.com/developer/interfaces/telnet-interface

1 Like

@thebearmay Do you know why telnet would send back "steam is closed" while when using nc -vc 192.168.0.18 4998 the message returned is "Connection to 192.168.0.18 port 4998 [tcp/*] succeeded!" ?

Some devices close the connection immediately after a successful command or after a small wait time. Also have seen where they close the stream, then go into a wait for the next command and renegotiate the connection as needed.

But the response from netcat (nc) clearly says that the connection succeeded and there is no indication of the connection being closed. This is before any command is sent. The fact that I can still send commands from both nc and telnet indicates that the connection is still open.

So just to clarify again. Clicking "Connect Telnet" does in fact open the connection, even though I get the "Stream is closed" error. Afterward, all commands work until the connection is manually closed.
After clicking "Disconnect Telnet" commands no longer work.