logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

problem using external webserver: msg#00000

Subject: problem using external webserver
My device sent SSDP message repeatly until the process ends.

below is the code

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <upnptools.h>
#include <ithread.h>
#include <ixml.h>
#include <upnp/upnp.h>

int CallbackEventHandler( Upnp_EventType EventType, void* , void* );


int main(){
    int rc,port,test,code;
    char *web_dir = "./web";
    char desc_doc_url[200],*desc_doc_name = "tvdevicedesc.xml", *ip_address;

    UpnpDevice_Handle device_handle;

    rc = UpnpInit (NULL, 0);
    if ( UPNP_E_SUCCESS == rc ) {
        const char* ip_address = UpnpGetServerIpAddress();
        unsigned short port    = UpnpGetServerPort();
       
        printf ("UPnP Initialized OK ip=%s, port=%d\n",
            (ip_address ? ip_address : "UNKNOWN"), port);
        //sprintf(desc_doc_url ,"http://%s:%d/%s", UpnpGetServerIpAddress(),port ,desc_doc_name );
        sprintf(desc_doc_url ,"http://%s/%s", UpnpGetServerIpAddress() ,desc_doc_name );
        printf("desc_doc_url = %s\n", desc_doc_url );
    } else {
        printf ("** ERROR UpnpInit(): %d", rc);
        printf ("\n");
        exit (EXIT_FAILURE); // ---------->
    }

/*    if( UPNP_E_SUCCESS == UpnpSetWebServerRootDir(web_dir) ){
        printf("Webserver_setdir succeed.\n");
    }else printf("Webserver_setdir failure.\n");

    if( UPNP_E_SUCCESS == UpnpEnableWebserver(TRUE) ){
        printf("Webserver succeed.\n");
    }else printf("Webserver failure.\n");*/

    if( UPNP_E_SUCCESS == (test = UpnpRegisterRootDevice( desc_doc_url
                        ,CallbackEventHandler ,&device_handle , &device_handle)) ) {
printf("DEBUG point\n");
    }else printf("UpnpRegisterRootDevice failure.\n");

/*    if( UPNP_E_SUCCESS == (test = UpnpRegisterRootDevice2( UPNPREG_URL_DESC , desc_doc_url , 0
                    , 0 ,CallbackEventHandler ,&device_handle , &device_handle)) ) {
printf("DEBUG point\n");
    }else printf("UpnpRegisterRootDevice2 failure.\n");*/

printf("UPNP_E = %d\n",test);

    if( UPNP_E_SUCCESS == UpnpSendAdvertisement( device_handle, 30 ) ){
        printf("device advertisement succeed.\n");
    }else printf("device advertisement failure.\n");

/*    if( UPNP_E_SUCCESS == UpnpUnRegisterRootDevice( device_handle ))
        printf("Unregister succeed.\n");
    else
        printf("Unregister failure.\n");
*/
    if( UPNP_E_SUCCESS == UpnpFinish() ){
        printf("device finish succeed.\n");
    }else printf("device finish failure.\n");
while(1){};
}
int CallbackEventHandler( Upnp_EventType EventType, void* Event, void* Cookie )
{
printf("in callback function...");

    switch( EventType ) {
        default:
            printf("UNKOWN EVENT TYPE\n");
    }

    return 0;
}

}

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
UPnP-SDK-discuss mailing list
UPnP-SDK-discuss@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/upnp-sdk-discuss
<Prev in Thread] Current Thread [Next in Thread>