How check specific TCP port through script?

I would like to monitor devices through RouterOS.
I have several devices accessing to internet through GPRS modems, so I need to use dyndns clients, but when pinging resolved hostname it could happens my device is powered off and resolved IP hostname could be assigned to different user.
In Dude I solved this making TCP test on specific ports.

I would like to make this test on RouterBoards, is there a way?
thanks.

I forget, I’ve seen there are topics about checking TCP port downloading webpage; I can’t so this because on specific port I’ve got servers (not http) running…