Example 1 -
Very simple example of fetching a single page from a normal web server.
No authentication is required, SSL is not used and no content is required
in the "GET" request.
The most recent version of the 4c demo application duplicates this
code almost verbatim.
The program is fccom.demo.1.
If you need to download the most recent 4c demo programs here's the link:
4C Demo Application
/*
* Allocate the connection, and specify the Server as 4csoftware.com
* This will use the default http port 80.
* reply content is set into the 4C var replycontent.
* StatusMessage and StatusCode are displayed to the user and are saved in
* the 4C variables statuscode and statusmsg.
* Any error message is automatically displayed to the user.
*/
if ((connident = FCCom::Alloc("Server","4csoftware.com")) < 0)
return -1;
rc = FCCom::HttpRequest(connident,"GET","/index.html","reply-content",replycontent);
sys.message(SM_INFO|SM_PIPEDELIM,"Status",FCCom::GetOption(connident,"Status"),"StatusMessage",FCCom::GetOption(connident,"StatusMessage"));
statuscode = atoi(FCCom::GetOption(connident,"Status"));
statusmsg = FCCom::GetOption(connident,"StatusMessage");
FCCom::Free(connident);