NetProg

 


   

NETPROG  PRESENTATION

 

  OverView
  Functionalities
  Programming
API
C Examples
  Download
HTTP example
C NetProg Programming
IP client server Connection Dialog Examples
TCP yes yes IP_PROTO_TCP TCP example
FTP yes no IP_PROTO_FTP FTP example
HTTP yes no IP_PROTO_HTTP HTTP example
SMTP yes no IP_PROTO_SMTP SMTP example
POP yes no IP_PROTO_POP POP example
DNS yes no IP_PROTO_DNS DNS example
DG yes yes IP_PROTO_DG USER_DEFINED example
IO          
STORE yes - IO_PROTO_STORE ANY  example
FIXED SIZE yes - IO_PROTO_FIOP  USER_DEFINED example
DATABASE          
ODBC yes - DB_PROTO_ODBC  DB example
ORACLE yes  -  DB_PROTO_ORACLE  DB example 
SQL/DS      DB_PROTO_SQLDS  DB example 

 

 

#include "mx.h" 
#include "http.h"

int SendRequest (MXMessage* pmessage, MXCom* pcom, void* AppField)
{
   char slength[10];
   char Request[250];
   char* NumeroLT;
   BUFFERPARM Buffer;
 

 

   MXSetValue (pmessage, "Request-Line", 1,

                  "GET http://sourceforge.net/tracker/?group_id=29057&atid=410216 HTTP/1.0");

   MXSetValue (pmessage, "Host", 1, "www.sourceforge.net");

   MXSetValue (pmessage, "Accept" , 1,

                      "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel,\

                       application/msword, application/vnd.ms-powerpoint, */*");

   MXSetValue (pmessage, "Accept-Language",1, "fr");

   MXSetValue (pmessage, "Accept-Encoding",1, "gzip, deflate");

   MXSetValue (pmessage, "User-Agent", 1, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)");

   MXSetValue (pmessage, "Proxy-Connection",1, "Keep-Alive");

   MXSetValue (pmessage, "Pragma" , 1, "no-cache");


   
   return 1;
}

int RecvResponse (MXMessage* pmessage, MXCom* pcom, void* AppField)
{
   BUFFERPARM* Buffer;
   STRING Response;
   int i = 0;
   int j = 0;
   

   Response = (STRING)MXGetValue (pmessage, "Status-Line", 1);
   Buffer = (BUFFERPARM*)MXGetValue (pmessage, "Content", 1);

 

/* RETURN url is in Buffer->BufferContent */
 

   FILE*f = fopen ("C:/response.html", "wt");
   fwrite (buffer->BufferContent, 1, buffer->BufferSize, f);
   fclose (f);

 


   free (Buffer->BufferContent);
   free (Buffer);
   return 1;
}



void main ()

{

   MX mx;
   MXMessage* pmessage;
   MXCom* HTTPCom;

/* Initialize MX manager */

   MXInit (&mx, MXSERVER, NULL, NULL, 0, NULL);

/* Connect to http server */

   HTTPCom = MXOpenTCP (&mx, "www.sourceforge.net", 80, IPPROTO_HTTP, NULL, NULL, TRUE);
   if (!HTTPCom) return;

   MXAddComCallBack (&mx, HTTPCom, HTTP_SYS, "Response",MXONRECV, RecvResponse, NULL); 
   MXAddComCallBack (&mx, HTTPCom, HTTP_SYS, "Request", MXONSEND, SendRequest,  NULL); 


/* Put message in queue */

   pmessage = MXPutMessage (HTTPCom, HTTP_SYS, "Request");

   MXDispatchEvents (&mx, 0);

   MXEnd (&mx);

}