开发者

Optimal way to stream stock prices from c++ server using tcp to websockets

I have a high performance C++ server getting live stock data directly from the major exchanges (Think GB of data per day). It calculates statistics that are used in monitoring the marke开发者_运维知识库t. I have it using a direct tcp socket to stream the statistics back to a GUI in C++ on a local box. The server sends back data (32 bytes) every second for 2500 stocks. This is not a problem and seems to work fine.

I am thinking about using some of the very nice visualization libraries available in javascript to interpret the data. Knowing that javascript does not deal with binary very well, (all the data is comming back is in C structs) What are my options?

My biggest concern is that having to send the messages via ASCII. Ideally what I want is a way to send my messages via the C struct and have my gui read them efficiently (without having to convert (expensive)).

I have read the Websocket api and it does not seem to be geared for what I want to do. Are there any other technologies that would do what I am looking for while allowing me to use all the nice javascript ui/visualization code.

Thanks


I'd look into a relational database where you can store your data. Then you'd have a platform where you can talk to for your data. It's the most reliable and felxible scenario.


If you can utilize/create a client (server-side socket) that can translate your more concise C/C++ structures into an object reference (as JSON), then do broadcasts to channels on an MQ (Pub/Sub) server, that may be easiest start...

from there, you can have browser-client connecting to a server (WebSocket wrappers like socket.io/SignalR should work), where clients can connect, then those connections simply subscribe to your pub/sub server, passing messages to said clients.

From there, you client can deal with the data in whatever way it likes (JS).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜