Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

External Web Server

2009-05-19
2012-12-14
  • Anthony Massa
    Anthony Massa
    2009-05-19

    I am trying to get UPnP support working on my Linux box (Fedora Core 5).  I am using the thttpd web server so I don't need (or want) the web server support included with pupnp/libupnp.  What I want is for the device to show up via UPnP on the client machine, but when the user clicks on the device, the thttpd web server handles serving up the appropriate pages, content, etc.

    When I get the device to show up and click on it, the device ends up trying to serve up http://192.168.1.101:49152/index.html.  I think I need to change the port so it goes to port 80 for the web server to handle the requests...right?

    If I try to disable the web server in UPnP the device never shows up in the "My Network Places".  I have moved the call to UpnpEnableWebserver around, but it doesn't seem to allow the UPnP advertisement to work properly if I have the call in there.  Here are the calls into the UPnP API I am using:

        status = UpnpInit(ip_address, port);

        status = UpnpEnableWebserver(0);

        status = UpnpRegisterRootDevice2(UPNPREG_FILENAME_DESC,
                                                                "tvdevicedesc.xml",
                                                                 0,
                                                                 1,
                                                                &DeviceCallbackEventHandler,
                                                                 NULL,
                                                                &device_handle);

        status = UpnpSendAdvertisement(device_handle, 100);

    Any help is appreciated to assist me in figuring out what I'm doing wrong.

    Thanks.

     
    • zephyrus
      zephyrus
      2009-08-20

      Hi,

      From what I understand after reading the libupnpd internal for a while,
      the web server plays a few roles.
      (1)  - one is to server the XML description of the device.
      (2-a)  - the other is optional, but it may want to process "POST" request
         to handle the request to the device  sent by "POST" HTTP packet.
         The web server then invoke appropriate action of the device.

      (2-b) If the webserver is not built in, and "POST" is not handled by such,
               the device needs to handle "M-POST" request.
              But this is not done by sample applications and I am not sure
             how to handle that.

      So in your case, if you would like to use the external web server,
      then you must handle either 2-a, or 2-b.
      Handling "POST" by an external webserver, which in turn, somehow invokes
      the actions of a device using libupnp routines seems to be rather difficult, and so
      you probably need to handle 2-b.

      You may need to modify XML description somewhat, but I am not sure of this yet.