Toolkit Tutorial: Advanced Programming


#include <stdio.h>
#define DX_API_PUBLIC
#include "dt_smiles.h"
#include "dt_http.h"

int main () {
 
dt_Handle server , transfer ;

 
/* create a web service */
 
server = dt_alloc_http_server ( 8080 );

 
/* loop forever */
 
for (;;) {
   
/* get a request */
   
if ( NULL_OB == ( transfer = dt_http_get ( server ))) {
     
fprintf ( stderr , "poll..." );
     
continue ;
   
}
   
/* put a response */
   
dt_setstring ( transfer , 11 , "htt_content" , 4 , "ping" );
   
dt_setinteger ( transfer , 8 , "htt_code" , 200 );
   
dt_http_put ( transfer );
   
dt_dealloc ( transfer );
 
}
 
return 0 ;
}