A powerful feature that sends text to a TCP server program on a remote machine.
numero = 265[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.Example:[tcpconnect host=webdna.us&port=80][tcpsend]GET / HTTP/1.0[unurl]%0D%0A%0D%0A[/unurl][/tcpsend][/tcpconnect]In this example, the http command equivalent to the URL "http://www.webdna.us" 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.
[tcpconnect host=internic.net&port=43][tcpsend]webdna.us[unurl]%0D%0A%0D%0A[/unurl][/tcpsend][/tcpconnect]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!
Parameter | Description |
---|---|
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 |
[text]host=[listmimeheaders name=host&exact=false][value][/listmimeheaders][/text][tcpconnect host=[host]][tcpsend]GET [thisurl]?get=false HTTP/1.0HOST: [host][/tcpsend][/tcpconnect]Result:HTTP/1.0 200 OKContent-type: text/htmlContent-Length: 29Hello World!With the 'SKIPHEADER=T' parameter...
[tcpconnect host=[host]][tcpsend skipheader=T]GET [thisurl]?get=false HTTP/1.0HOST: [host][/tcpsend][/tcpconnect]Results: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][!][/!][/tcpsend][/writefile][/tcpconnect]Another Example to get the change euro/dollar with an API:The full URL is http://rate-exchange.herokuapp.com/fetchRate?from=USD&to=EURFor this one, we have to simulate a real browser
[text]h=rate-exchange.herokuapp.com[/text][text]p=/fetchRate?from=USD&to=EUR[/text][text]n=[unurl]%0D%0A[/unurl][/text][text]USchange=[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][!][/!][/tcpsend][/tcpconnect][/text][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]host=business.comcast.com[/text][text]path=/ethernet/private-line[/text][text]n=[unurl]%0D%0A[/unurl][/text][text]content=[/text][text]comcast_result=[tcpconnect host=[host]&port=443&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][!][/!][/tcpsend][/tcpconnect][/text]comcast_result=[comcast_result][tcpsend]Text to Send[/tcpsend]
[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 host=webdna.us&port=80]
[tcpsend]GET / HTTP/1.0[unurl]%0D%0A%0D%0A[/unurl][/tcpsend]
[/tcpconnect]
[tcpconnect host=internic.net&port=43]
[tcpsend]webdna.us[unurl]%0D%0A%0D%0A[/unurl][/tcpsend]
[/tcpconnect]
Parameter | Description |
---|---|
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 |
[text]host=[listmimeheaders name=host&exact=false][value][/listmimeheaders][/text]
[tcpconnect host=[host]][tcpsend]
GET [thisurl]?get=false HTTP/1.0
HOST: [host]
[/tcpsend][/tcpconnect]
[tcpconnect host=[host]][tcpsend skipheader=T]
GET [thisurl]?get=false HTTP/1.0
HOST: [host]
[/tcpsend][/tcpconnect]
[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][!]
[/!][/tcpsend][/writefile]
[/tcpconnect]
[text]h=rate-exchange.herokuapp.com[/text]
[text]p=/fetchRate?from=USD&to=EUR[/text]
[text]n=[unurl]%0D%0A[/unurl][/text]
[text]USchange=
[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][!]
[/!][/tcpsend]
[/tcpconnect]
[/text]
[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]host=business.comcast.com[/text]
[text]path=/ethernet/private-line[/text]
[text]n=[unurl]%0D%0A[/unurl][/text]
[text]content=[/text]
[text]comcast_result=[tcpconnect host=[host]&port=443&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][!]
[/!][/tcpsend]
[/tcpconnect][/text]
comcast_result=[comcast_result]
DOWNLOAD WEBDNA NOW!
A list of user-submitted tips ...
WebDNA reference...
[biotype]BioType is a behavioral biometrics WebDNA function based on ADGS research and development (from version 8...
Technical Change HistoryThis Technical Change History provides a reverse chronological list of WebDNA changes...
AWS Raw WebDNA LAMP-Plus WebServerAmazon Web Services (AWS) README for Machine Image ID...
WebDNA ModulesA list of the currently available modules...
...
[random]will display a random number...
[append][append db=base...
[function]This context enables the WebDNA programmer to call a previously defined block of WebDNA code...
[removelineitem]...
[clearlineitems]Remove all line items from the specified shopping cart...