Technical References - [tcpsend]

A powerful feature that sends text to a TCP server program on a remote machine.

[tcpsend]Text to Send[/tcpsend]

To embed the results of a TCP session into one of your pages, place a [tcpconnect] context into a template, and place [tcpsend] contexts inside of that. The TCPSend steps contained inside the context execute, and any returned value displays in place of the context. Any [xxx] tags inside the context are first substituted for their real values before the TCPSend executes.

[tctsend] and [tcpconnect] will allow you to recover information from remote web pages and servers (change rates, airports arrivals and departures, payment gateways, package tracking....)

TCPConnect does nothing by itself; you must insert one or more [tcpsend] contexts inside it to perform any real work. TCPConnect establishes a connection to the TCP server program, and provides an environment for the TCPSend contexts to do their work and return text results.

[tcpsend]GET / HTTP/1.0[unurl]%0D%0A%0D%0A[/unurl][/tcpsend]

In this example, the http command equivalent to the URL "" executes, and the results (the home page for that site) display. Notice the use of [unurl] to send <Carriage Return><LineFeed><Carriage Return><LineFeed> as part of the TCPSend text. If you do not send the correct sequence of 2 CR/LF characters, the remote web server never returns any text, and the TCPSend times out while waiting for a response.


This example performs the equivalent of a WHOIS command which queries the Internet for information about a particular domain name. Substitute your own domain name and see what you get!

end(Optional) text to look for indicating end of line. Often [TCPSend end=
] is used to look for <carriage return><line feed> as the end of line indicator, as is necessary when communicating with email POP servers or FTP servers.
Not necessary for communication with HTTP protocol, because the remote server disconnects automatically at the end of the session.
skipheader=T(Optional) instructs the WebDNA engine to'strip' the MIME headers from the result

Using 'SKIPHEADER=T' in the [tcpsend] context will instruct the WebDNA engine to'strip' the MIME headers from the result (assuming that you are invoking an HTTP Get or Post).

For example, a simple HTTP GET without the SKIPHEADER set to 'T'
[text]host=[listmimeheaders name=host&exact=false][value][/listmimeheaders][/text]
[tcpconnect host=[host]][tcpsend]
GET [thisurl]?get=false HTTP/1.0
HOST: [host]

HTTP/1.0 200 OK
Content-type: text/html
Content-Length: 29

Hello World!

With the 'SKIPHEADER=T' parameter...

[tcpconnect host=[host]][tcpsend skipheader=T]
GET [thisurl]?get=false HTTP/1.0
HOST: [host]


Hello World!

The 'skipheader' option is also handy when using TCPSend to fetch a binary file from a remote server.
For Example:
[tcpconnect host=[host]]
[writefile file=test.jpg][tcpsend skipheader=T]GET /[path_to_jpg] HTTP/1.0[unurl]%0D%0A%0D%0A[/unurl][!]
[/!]Host: [host][unurl]%0D%0A%0D%0A[/unurl][!]

Another Example to get the change euro/dollar with an API:
The full URL is
For this one, we have to simulate a real browser
[tcpconnect host=[h]&port=80]
[tcpsend skipheader=T]GET [p] HTTP/1.0[n][!]
[/!]Host: [h][n][!]
[/!]User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)[n][n][!]

[math show=T]USdollar=[format 10.2f][middle startafter="rate":"&endbefore="][USchange][/middle][/format][/math]

As it is requested by most servers, it is important to insert the host inside the [tcpsend ][/tcpsend ] context like in the example below


[text]comcast_result=[tcpconnect host=[host]&portD3&ssl=T]
[tcpsend skipheader=T]GET [path] HTTP/1.0[n][!]
[/!]Host: [host][n][!]
[/!]User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)[n][!]
[/!]Content-Type: text/html[n][!]
[/!]Content-Length: [countchars][content][/countchars][n][n][!]



Top Articles:

WebDNA reference

A list of all WebDNA instructions...

Download WebDNA Applications

WebDNA applications...

WebDNA Libraries

A list of available libraries for WebDNA...


A compilation of some user's questions...

AWS Raw WebDNA LAMP-Plus WebServer

Amazon Web Services (AWS) README for Machine Image ID...


BioType is a behavioral biometrics WebDNA function based on ADGS research and development (from version 8...

Related Readings:


UNIX: Setting up WebDNA - ODBC - Database Server...


Copy a file with the content you want on your webspace...


Enable the WebDNA programmer to input XML data into a WebDNA variable...




[shownext] is a special context used to create links (or more accurately...


Triggers provide a mechanism for doing something on a regular timed basis...