HttpDaemon


int HttpDaemon ( HttpConfigData *pConfig )




 
Starts the http server.

 
pConfig pointer to the config data for the server.
 
Returns 0 it daemon was started, or an error code greather zero:


HTTP_ERR_NONE 0 no error
HTTP_ERR_SOCKET 1 socket error
HTTP_ERR_ISRUNNING 2 nmb server is running
HTTP_ERR_WRONGPATH 4 the file path is wrong
HTTP_ERR_WRONGIP 5 the ip address is wrong
HTTP_ERR_INIT 6 initialization error

 

Description for HttpConfigData:

char cIpAddress[64] ip addres off the http-server.
use "0.0.0.0" for all addresses.
 
char cDefaultExt[32] default file name for access to paths.
if this value is "" then path uls (ie. "/abc/")
wont be moved th files.
 
char cAuthRealm[64] is the realm value for the authorization.
 
char cFilePath[256] is the base path for server files.
 
unsignedshort usTcpPort is the tcp port for the server.
usually this value is 80.
 
unsigned uUserOffset start offest for user parameters.
set to zero, and then register plugins.
 
int iMaxConnections maximum count of client connections.
 
int iPriority taks priority 0-256.
 
HttpRequestCB pCbRequest callback for a client request
use NULL for no callback
is called if a browser sends arequest.
 
HttpConnectCB pCbConnect callback for client connection
use NULL for no callback
is called if a browser opens a new
connection to the server
 
HttpPasswordCB pCbPassword callback for password returning
use NULL for no callback
is called to get a pssword for a user
 
HttpDisconnectCB    pCbDisconnect callback for client disconnection
use NULL for no callback
is called if a browser connection
is broken
 

 

See here for the depentencies of the callbacks.

 

i.e.:

    ...
    HttpConfigData sConfig;

    memset(&sConfig,0,sizeof(sConfig));

    strcpy(sConfig.cIpAddress ,"0.0.0.0"   );
    strcpy(sConfig.cDefaultExt,"index.html");

    sConfig.pCbRequest = MyRequestCallback;	

    // register plugins at this place
    // ...

    if(HttpDaemon(&sConfig))
        {
        // error
        }
    else{
        // wait until end
        // ... 

        HttpStopDaemon();
        } 
  

 


see also:

AzHttp Overview | HttpStopDaemon | HttpTransmitCallback | HttpTransmitFile | HttpTransmitGoto | HttpTransmitMemory