After looking for a C library that implemented a web server, I was taught about Mongoose. I have actually made it work through several examples that make the call to the callback function that actually treats the incoming and outgoing data. I am using on Windows, compiling and debugging with Visual Studio 2008.
I called it session and it follows:
int CHttpsCom::Session( void )
{
struct mg_context *ctx;
const char *options[] = {
"listening_ports", "443s",
#ifdef _DEBUG
"ssl_certificate", "c:\\temp\\cert.pem",
#else
"ssl_certificate", "cert.pem",
#endif
NULL
};
ctx = mg_start( &callback, NULL, options );
if( !ctx )
return 1;
//getchar(); // Wait until user hits "enter"
while ( LeaveIt == false );
Sleep(3500);// without this it won't work
mg_stop( ctx );
return 0;
}
100% of the examples I have noticed most examples use getchar to synchronize the end of the session with the ending if the callback execution. I have this LeaveIt flag that is set after I get a post message. If I don't use the Sleep above, I get a deadlock internal to the library. Is there any better way of handling this wait for the the callback ending ?
Thanks.