cachance7
cachance7

Reputation: 943

How to create streaming endpoint on server?

I'm currently serving data in two ways but am considering a third:

  1. REST endpoints -- access to existing data on the server which is relatively small
  2. Listening for socket.io messages -- access to continuous updates about the server internals that all connected clients should receive
  3. Streaming endpoint -- access to a very large serial data object that may or may not currently exist, but if the endpoint is valid then clients can expect it will contain data very soon. Clients that connect to the streaming endpoint expect the stream to start at the beginning of the data and terminate at the end (additional optional 'begin' & 'end' parameters aside).

Given that I'm using node.js, socket.io, and express, what server-side technology would best fit my needs? Does this approach make sense?

Upvotes: 4

Views: 1294

Answers (1)

Timothy Strimple
Timothy Strimple

Reputation: 23060

You can do this with express (or more accurately the underlying functionality build into the http server). You can make repeated calls to request.write and call request.end once you're done sending data. Alternatively, if you have a stream, you can pipe that to the response.

Upvotes: 1

Related Questions