GDBMS 1.0
|
00001 #include "soapGDBMS_USCOREbindingService.h" 00002 #include "GDBMS_USCOREbinding.nsmap" 00003 #include <pthread.h> 00004 #include <fstream> 00005 #include "some_functions.h" 00006 //void *process_request(void *soap); 00007 //void soap_serve(struct soap *); 00008 #define BACKLOG (100) 00009 // Max. request backlog 00012 00258 int main(int argc, char **argv) 00259 { 00260 //printf(" \n Service opened. \n "); 00261 // struct soap soap; 00262 // soap_init(&soap); 00263 GDBMS_USCOREbindingService server; 00264 if (argc < 2) // no args: assume this is a CGI application 00265 { 00266 00267 00268 server.serve(); 00269 00270 00271 } 00272 else 00273 { 00274 00275 return server.run(strtoint(argv[0])); 00276 /* 00277 soap.send_timeout = 60; // 60 seconds 00278 soap.recv_timeout = 60; // 60 seconds 00279 soap.accept_timeout = 3600; // server stops after 1 hour of inactivity 00280 soap.max_keep_alive = 100; // max keep-alive sequence 00281 void *process_request(void*); 00282 struct soap *tsoap; 00283 pthread_t tid; 00284 int port = atoi(argv[1]); // first command-line arg is port 00285 SOAP_SOCKET m, s; 00286 m = soap_bind(&soap, NULL, port, BACKLOG); 00287 if (!soap_valid_socket(m)) 00288 exit(1); 00289 fprintf(stderr, "Socket connection successful %d\n", m); 00290 for (;;) 00291 { 00292 s = soap_accept(&soap); 00293 if (!soap_valid_socket(s)) 00294 { 00295 if (soap.errnum) 00296 { 00297 soap_print_fault(&soap, stderr); 00298 exit(1); 00299 } 00300 fprintf(stderr, "server timed out\n"); 00301 break; 00302 } 00303 //fprintf(stderr, "Thread %d accepts socket %d connection from IP %d.%d.%d.%d\n", i, s, (soap.ip >> 24)&0xFF, (soap.ip >> 16)&0xFF, (soap.ip >> 8)&0xFF, soap.ip&0xFF); 00304 tsoap = soap_copy(&soap); // make a safe copy 00305 if (!tsoap) 00306 break; 00307 pthread_create(&tid, NULL, (void*(*)(void*))process_request, (void*)tsoap); 00308 00309 } 00310 00311 */ 00312 00313 } 00314 //soap_done(&soap); // detach soap struct 00315 return 0; 00316 } 00317 /* 00318 void *process_request(void *soap) 00319 { 00320 pthread_detach(pthread_self()); 00321 00322 soap_serve((struct soap*)soap); 00323 soap_destroy((struct soap*)soap); // dealloc C++ data 00324 soap_end((struct soap*)soap); // dealloc data and clean up 00325 soap_done((struct soap*)soap); // detach soap struct 00326 free(soap); 00327 return NULL; 00328 00329 00330 00331 00332 } 00333 00334 */ 00335