class ref name: msgtrans
class name: msgtrans_o
category-group: transport
layer: 8
header file: z_msgtrans.h
libraries: libz00.lib libz01.lib libz02.lib libz03.lib libz04.lib libz05.lib libz06.lib libz07.lib libz08.lib synopsis.
The msgtrans_o class is a wrapper, actually an exemplar of sorts, for the msgtrans_axiom_o class. It contains a pointer to an 'axiom instance', and all operations are forwarded to that class. This class adds no additional functionality; it is purely a wrapper mechanism. This class is the one you should use in the application to read or write data to a socket. The socket can be on the same computer as the msgtrans_o object instance, across a LAN, or a web server in the internet on the other side of the planet. description.
The message transport object, or msgtrans_o, is an object at the top of a chain of "support" classes dealing with moving a set of bytes from one place to another. A "set of bytes" means a block of characters, a data stream, a block of text, or whatever words you use to describe data, put into things called "bytes" and lumped together. member functions (primary)
msgtrans_o_o(<args>)examples.
SIGNATURE: kw_parser_o ()
This is how to do a simple http request using the Z Directory:
#includehistory.#include "z_msgtran.h" int main() { int ie, ie2; size_t nb; z_start(); string_o the_host = "www.vettrasoft.com"; string_o query, reply; msgtrans_o mt; msgtrans_sockaddr_o addr; mt.use_packets(FALSE); mt.do_multiget(); query = "GET / HTTP/1.1\n"; query += "Accept: */*"; query += "Accept-Language: en\n"; query += "Accept-Encoding: gzip, deflate\n"; query += "Host: www.vettrasoft.com"; query += "Connection: Keep-Alive\n"; query += "\n\n"; addr.set_port (80); addr.set_host (the_host); mt.set_address (addr, &ie); ie = mt.connect(); if (ie) exit(1); //.......................................................... // send the query-message //.......................................................... nb = query.size(); ie = mt.put (query, &ie2, nb); if (ie) exit(1); //.......................................................... // wait for, get reply; then process it //.......................................................... string_o answer = "01234567890123456789"; nb = answer.size(); ie = mt.get (answer, &ie2, &nb); if (ie) exit(1); std::cout << "http reply from " << the_host << ":\n"; std::cout << answer << std::endl; return 0; }
Tue 09/02/1997: made "init()"; ("msg. transp. packet") packetizing added Wed 11/19/1997: "==" operators no longer inlined; hp-ux compile barfed Fri 12/26/1997: made the default for using packets to "true" ??? 01/20/1998: bug fix: added a wait-for-packets loop ??? 07/04/1998: moved up to layer 8 (from layer 5) Thu 03/29/2012: found c-tor calls [L-09] "make_gsocket_msgtrans()" this file, 08 -> 09. Sat 08/18/2012: mods to handle http messages: loop until "get()" fails