This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Real-time data display on HTTP Web Server

Hi all,

I'm developing a HTTP web server on a F28M35 Concerto Control Card that routinely send a set of data to a browser client on PC. I have read into this matter and discover that a scheme of "Long Polling" for HTML is use to poll data from a server. I wonder whether this scheme is supported by TI-RTOS.

Alternatively, can I use TI-RTOS native functions to continuously push data to the browser whenever new data is available? 

  • Hac,

    Can you please post a link to information about this “long polling” scheme?  I’m not sure if this is supported by NDK or not.  If you provide more details about what you are looking for I can look into this more...

    Thanks,
    Scott

  • Hi Scott,

    This a basic explanation for long polling in HTTP server: 

    What I have been doing is that I put the HTML and the polling code for the server in a SD card. Whenever a client access these files via Concerto HTTP server, a polling procedure is initiated in which the client continuously request for new data from the server. What I don't understand is the way the Concerto server output the data to the client. Can I repeatedly run a CGI function to display the data on the client's browser each time the PHP code initiate a request to the server?

  • Hi Hac,

    OK, thanks.  I don’t know if this is supported or not, but will check with others, and see if they have any recommendations. 

    I’ll post back when I know more…

    Regards,
    Scott

  • Hi Hac,

    Hac Le said:
    Can I repeatedly run a CGI function to display the data on the client's browser each time the PHP code initiate a request to the server?

    I'm not sure you should do this.  The CGI is meant to be spawned when a request comes in from a client.  The CGI function will run in the context of a Task thread, and a new Task thread is spawned for each CGI request (and hence the code of that CGI function is run anew, with each request).

    I'm wondering if something like the following could work for you, using the CGI model:

    1. A CGI daemon runs on the HTTP server, awaiting for a client to connect.  The CGI task will act as a "first step" in the long polling communications (basically just the connection).

    2. When the client connects, a new Task thread is spawned, and it runs the code of your CGI function (let's call this Task A).  The HTML socket is passed to the Task A as an argument.

    3. Task A could do the following:

        a. create a new Task thread (let's call this Task B) and passes the HTML socket as an argument to Task B.

        b. Task A then returns 0 to indicate that the HTML socket was passed to another thread

        c. Task A exits/ends

    4. Task B

    a. this Task will keep the connection open with the client and handle the long polling logic/communications between the client and server that are connected over the HTML socket (that was received via Task A)

    b. when data is ready, it can push it out to the client

    c. it could do this either when the server knows that data is ready to be pushed, or if a request for data from the client is received, and the data is ready to be pushed.

    5. The process repeats if another client connects - Task A' will spawn, create Task B', same as above.

    Let me know what you think.  Does this idea help you with your problem?

    Steve