problem using external webserver
正文 王 <[email protected]> Tue, 13 Nov 2007 10:27:00 +0800
| Newsgroups | gmane.linux.upnp-sdk.general |
|---|---|
| Message-ID | <[email protected]> |
--===============1454925822==
Content-Type: multipart/alternative;
boundary="_e173b455-cdf1-4aca-b206-7f8cf40b90c2_"
--_e173b455-cdf1-4aca-b206-7f8cf40b90c2_
Content-Type: text/plain; charset="big5"
Content-Transfer-Encoding: quoted-printable
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 =3D "./web";
char desc_doc_url[200],*desc_doc_name =3D "tvdevicedesc.xml", *ip_add=
ress;
UpnpDevice_Handle device_handle;
rc =3D UpnpInit (NULL, 0);
if ( UPNP_E_SUCCESS =3D=3D rc ) {
const char* ip_address =3D UpnpGetServerIpAddress();
unsigned short port =3D UpnpGetServerPort();
=20
printf ("UPnP Initialized OK ip=3D%s, port=3D%d\n",=20
(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() ,d=
esc_doc_name );
printf("desc_doc_url =3D %s\n", desc_doc_url );
} else {
printf ("** ERROR UpnpInit(): %d", rc);
printf ("\n");
exit (EXIT_FAILURE); // ---------->
}
/* if( UPNP_E_SUCCESS =3D=3D UpnpSetWebServerRootDir(web_dir) ){
printf("Webserver_setdir succeed.\n");
}else printf("Webserver_setdir failure.\n");
if( UPNP_E_SUCCESS =3D=3D UpnpEnableWebserver(TRUE) ){
printf("Webserver succeed.\n");
}else printf("Webserver failure.\n");*/
if( UPNP_E_SUCCESS =3D=3D (test =3D UpnpRegisterRootDevice( desc_doc_=
url=20
,CallbackEventHandler ,&device_handle , &device_h=
andle)) ) {
printf("DEBUG point\n");
}else printf("UpnpRegisterRootDevice failure.\n");
/* if( UPNP_E_SUCCESS =3D=3D (test =3D UpnpRegisterRootDevice2( UPNPRE=
G_URL_DESC , desc_doc_url , 0=20
, 0 ,CallbackEventHandler ,&device_handle , &device_h=
andle)) ) {
printf("DEBUG point\n");
}else printf("UpnpRegisterRootDevice2 failure.\n");*/
printf("UPNP_E =3D %d\n",test);
if( UPNP_E_SUCCESS =3D=3D UpnpSendAdvertisement( device_handle, 30 ) =
){
printf("device advertisement succeed.\n");
}else printf("device advertisement failure.\n");
/* if( UPNP_E_SUCCESS =3D=3D UpnpUnRegisterRootDevice( device_handle )=
)
printf("Unregister succeed.\n");
else
printf("Unregister failure.\n");
*/
if( UPNP_E_SUCCESS =3D=3D UpnpFinish() ){
printf("device finish succeed.\n");
}else printf("device finish failure.\n");
while(1){};
}
int CallbackEventHandler( Upnp_EventType EventType, void* Event, void* Co=
okie )
{
printf("in callback function...");
switch( EventType ) {
default:
printf("UNKOWN EVENT TYPE\n");
}
return 0;
}
}
--_e173b455-cdf1-4aca-b206-7f8cf40b90c2_
Content-Type: text/html; charset="big5"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class=3D'hmmessage'>
My device sent SSDP message repeatly until the process ends.<br><br>below=
is the code<br><br>#include <stdio.h><br>#include <stdlib.h>=
<br>#include <unistd.h><br>#include <upnptools.h><br>#include=
<ithread.h><br>#include <ixml.h><br>#include <upnp/upnp.h=
><br><br>int CallbackEventHandler( Upnp_EventType EventType, void* , v=
oid* );<br><br><br>int main(){<br> int rc,port,test,cod=
e;<br> char *web_dir =3D "./web";<br> =
char desc_doc_url[200],*desc_doc_name =3D "tvdevicedesc.xml", *ip_addres=
s;<br><br> UpnpDevice_Handle device_handle;<br><br>&nbs=
p; rc =3D UpnpInit (NULL, 0);<br> if ( UPNP=
_E_SUCCESS =3D=3D rc ) {<br> const c=
har* ip_address =3D UpnpGetServerIpAddress();<br>  =
; unsigned short port =3D UpnpGetServerPort=
();<br> <br>  =
; printf ("UPnP Initialized OK ip=3D%s, port=3D%d\n", <br>&nb=
sp; (ip_address ? ip_ad=
dress : "UNKNOWN"), port);<br> //spr=
intf(desc_doc_url ,"http://%s:%d/%s", UpnpGetServerIpAddress(),port ,desc=
_doc_name );<br> sprintf(desc_doc_ur=
l ,"http://%s/%s", UpnpGetServerIpAddress() ,desc_doc_name );<br> &n=
bsp; printf("desc_doc_url =3D %s\n", desc_doc_ur=
l );<br> } else {<br> &nb=
sp; printf ("** ERROR UpnpInit(): %d", rc);<br> &=
nbsp; printf ("\n");<br> exit =
(EXIT_FAILURE); // ----------><br> }<br><br>/* =
if( UPNP_E_SUCCESS =3D=3D UpnpSetWebServerRootDir(web_dir) )=
{<br> printf("Webserver_setdir succe=
ed.\n");<br> }else printf("Webserver_setdir failure.\n"=
);<br><br> if( UPNP_E_SUCCESS =3D=3D UpnpEnableWebserve=
r(TRUE) ){<br> printf("Webserver suc=
ceed.\n");<br> }else printf("Webserver failure.\n");*/<=
br><br> if( UPNP_E_SUCCESS =3D=3D (test =3D UpnpRegiste=
rRootDevice( desc_doc_url <br>  =
; ,C=
allbackEventHandler ,&device_handle , &device_handle)) ) {<br>pri=
ntf("DEBUG point\n");<br> }else printf("UpnpRegisterRoo=
tDevice failure.\n");<br><br>/* if( UPNP_E_SUCCESS =3D=3D=
(test =3D UpnpRegisterRootDevice2( UPNPREG_URL_DESC , desc_doc_url , 0 <=
br> &=
nbsp; , 0 ,CallbackEventHandler ,&device_handle , =
&device_handle)) ) {<br>printf("DEBUG point\n");<br>  =
; }else printf("UpnpRegisterRootDevice2 failure.\n");*/<br><br>printf("UP=
NP_E =3D %d\n",test);<br><br> if( UPNP_E_SUCCESS =3D=3D=
UpnpSendAdvertisement( device_handle, 30 ) ){<br> &nbs=
p; printf("device advertisement succeed.\n");<br> =
}else printf("device advertisement failure.\n");<br><br>/* &n=
bsp; if( UPNP_E_SUCCESS =3D=3D UpnpUnRegisterRootDevice( device_han=
dle ))<br> printf("Unregister succee=
d.\n");<br> else<br> &nbs=
p; printf("Unregister failure.\n");<br>*/<br> if( UPNP_=
E_SUCCESS =3D=3D UpnpFinish() ){<br> =
printf("device finish succeed.\n");<br> }else printf("=
device finish failure.\n");<br>while(1){};<br>}<br>int CallbackEventHandl=
er( Upnp_EventType EventType, void* Event, void* Cookie )<br>{<br>printf(=
"in callback function...");<br><br> switch( EventType )=
{<br> default:<br>  =
; printf("UNKOWN EVENT TYPE\n");<br=
> }<br><br> return 0;<br>}<br><br>}<b=
r><br></body>
</html>
--_e173b455-cdf1-4aca-b206-7f8cf40b90c2_--
--===============1454925822==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-------------------------------------------------------------------------
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/
--===============1454925822==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
UPnP-SDK-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/upnp-sdk-discuss
--===============1454925822==--