uCon HomePage

Script Cmd: TCP

TCP [-cdfh:p:r] {sub-command}  [args] ...

The specific intent of this command is to allow a uCon script to communicate with some other uCon session that has an active telnet server; however, it is useful for communicating with any other TCP based server. By default the port is 23 and the host name is that of the host PC (IP = $MYIP); however the -p and -h options allow the user to override these defaults.


-c              omit '\n' from the end of line
-d {msecs}      delay (milliseconds) between commands (used with SEND)
-f              flush the response message (if any)
-h {hostname}   override default of $MYIP
-p {port #}     override default port number of 23 (telnet)
-r              use "\r\n"  for line termination

Current sub-commands supported:

Syntax: TCP SEND {"string to other TCP session"} ["next string"] ....
The "string to other TCP session" is terminated with a newline and passed to the remote server as a single TCP packet.  Consider this a "one shot" telnet client, where the client simply establishes the connection with the server, sends over the string(s) and disconnects.  If more than one string is specified, then the -d option can be used to adjust the default of 1 second delay put between each string sent.


In this example, the TCP command interacts with the Synaccess NPC-22, a network power switch.
This single line connects to the telnet server (port 23) on host
It interacts with the opening connection messages by replying with the login id  and password (which in
this case are "admin" and "admin".
Then it uses a "/pset 1 1" command and logs out.
With this script put in a button or function key you have a single-click
poweron-poweroff control for any device that can be plugged into a remote power switch.

TCP -d 300 -h -p 23 SEND "/login" "admin" "admin" "/pset 1 1" "/logout"

Example 2...

Assume you just want to load down an embedded http server:

# TOP:
TCP -fc -h -p 80 SEND "GET / HTTP/1.1\r\n\r\n"
TCP -fc -h -p 80 SEND "GET /style.css HTTP/1.1\r\n\r\n"
TCP -fc -h -p 80 SEND "GET /test.bmp HTTP/1.1\r\n\r\n"
TCP -fc -h -p 80 SEND "GET /favicon.ico HTTP/1.1\r\n\r\n"