Socket programming with JS!

Discussion in 'Javascript' started by Boomer, Sep 9, 2006.

  1. Boomer

    Boomer Guest

    Hello,

    Is it possible to live-capture data with JS? The XMLHttpRequest() method is
    not really suitable for live data capture.

    Any hints/directions?

    TIA

    Boomer
    Boomer, Sep 9, 2006
    #1
    1. Advertising

  2. Boomer

    Tim Williams Guest

    "Boomer" <> wrote in message
    news:U0GMg.31228$...
    > Hello,
    >
    > Is it possible to live-capture data with JS? The XMLHttpRequest() method
    > is not really suitable for live data capture.
    >
    > Any hints/directions?
    >
    > TIA
    >
    > Boomer


    In what context ? js has no "native" file/stream functionality, so maybe
    there are existing objects which you could script to achieve your aim...

    Tim
    Tim Williams, Sep 9, 2006
    #2
    1. Advertising

  3. Boomer

    Tom Cole Guest

    Tim Williams wrote:
    > "Boomer" <> wrote in message
    > news:U0GMg.31228$...
    > > Hello,
    > >
    > > Is it possible to live-capture data with JS? The XMLHttpRequest() method
    > > is not really suitable for live data capture.


    To be honest, HTTP itself isn't really suitable for live data capture.
    The whole request, response thing, you know.....

    Any reason you couldn't use XmlHttpRequest with a timer?

    > >
    > > Any hints/directions?
    > >
    > > TIA
    > >
    > > Boomer

    >
    > In what context ? js has no "native" file/stream functionality, so maybe
    > there are existing objects which you could script to achieve your aim...
    >
    > Tim
    Tom Cole, Sep 10, 2006
    #3
  4. Boomer

    Boomer Guest

    "Any reason you couldn't use XmlHttpRequest with a timer?"



    The data is somewhat unpredictable and in many case repetitious. There is no
    way of knowing the data that is being captured is old or new when using
    XMLHttpRequest().



    Thanks for all your comments.



    Boomer
    Boomer, Sep 10, 2006
    #4
  5. Boomer

    VK Guest

    Boomer wrote:
    > The data is somewhat unpredictable and in many case repetitious. There is no
    > way of knowing the data that is being captured is old or new when using
    > XMLHttpRequest().


    XMLHttpRequest is simply a "virtual browser" (with very harrow
    functionality) programmatically created inside the real one. This way
    old data/new data question must be solved by the regular Web browsing
    means: by setting and checking cache-related headers. It can be also
    HEAD request made before GET/POST to see if you need to make new data
    request.
    If you are thinking of a socket listener, so you would get automated
    server notification on new data ready - then HTTP doesn't deal with
    such things. Respectively a web-browser has nothing to offer on this
    matter.
    VK, Sep 10, 2006
    #5
  6. Boomer wrote:

    > Is it possible to live-capture data with JS? The XMLHttpRequest() method is
    > not really suitable for live data capture.


    Though its name suggests the opposite, XMLHttpRequest() can be used to
    fetch non-XML data as well. And the connection doesn't need to point
    to the 'default' http daemon as well; e.g. http://12.34.56.789:585
    should take you to port 585 instead of (common) 80.

    But the service must accept HTTP-style socket communication anyhow if
    you want to connect from a javascript client.

    --
    Bart
    Bart Van der Donck, Sep 10, 2006
    #6
  7. Boomer

    Guest

    Boomer wrote:
    > The data is somewhat unpredictable and in many case repetitious. There is no
    > way of knowing the data that is being captured is old or new when using
    > XMLHttpRequest().


    One solution to this is to have a sequence number that is incremented
    on each request. The server keeps track of changes in status, and
    remembers the current sequence number t, and sends that sequence number
    with each request. When the client issues a request it sends the last
    sequence number it received u, the server sends any changes in the data
    between u and t.

    It requires a somewhat complex state machine running on the server, but
    the client side is easy enough.

    Typically you would put a limit on the age of sequence numbers, if the
    client sends one that is too old the server sends a 'keyframe' that
    includes all data, allowing the client to reset everything to the
    current status.

    The system is still poll driven rather than interrupt driven, but
    signifcantly reduces the traffic volume. (And it sounds like that is a
    goal in your case).

    HTH

    Sam
    , Sep 11, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Nagy
    Replies:
    1
    Views:
    4,761
    Mark Wooding
    Jan 27, 2009
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    944
    Jean-Paul Calderone
    Jan 27, 2009
  3. Laszlo Nagy
    Replies:
    0
    Views:
    526
    Laszlo Nagy
    Feb 1, 2009
  4. Steve Holden
    Replies:
    0
    Views:
    644
    Steve Holden
    Feb 1, 2009
  5. Steve Holden
    Replies:
    1
    Views:
    698
Loading...

Share This Page