Looking for a good method to transfer critical real time data over internet
Asked Answered
C

3

6

I am searching for a good method to transfer data over internet, and I work in C++/windows environment. The data is binary, a compressed blob of an extracted image. Input and requirements are as follows:

  1. 6kB/packet @ 10 packets/sec (60kBytes per second)
  2. Reliable data transfer

I am new to network programming and so far I could figure out that one of the following methods will be suitable.

  1. Sockets
  2. MSMQ (MS Message Queuing)

The Client runs on a browser (Shows realtime images on browser). While server runs native C++ code. Please let me know if there are any other methods for achieving the same? Which one should I go for and why?

Crossroads answered 22/10, 2012 at 6:9 Comment(0)
B
3

If the server determines the pace at which images are sent, which is what it looks like, a server push style solution would make sense. What most browsers (and even non-browsers) are settling for these days are WebSockets.

The main advantage WebSockets have over most proprietary protocols, apart from becoming a widely adopted standard, is that they run on top of HTTP and can thus permeate (most) proxies and firewalls etc.

On the server side, you could potentially integrate node.js, which allows you to easily implement WebSockets, and comes with a lot of other libraries. It's written in C++, and extensible via C++ and JavaScript, which node.js hosts a VM for. node.js's main feature is being asynchronous at every level, making that style of programming the default.

But of course there are other ways to implement WebSockets on the server side, maybe node.js is more than you need. I have implemented a C++ extension for node.js on Windows and use socket.io to do WebSockets and non-WebSocket transports for older browsers, and that has worked out fine for me.

But that was textual data. In your binary data case, socket.io wouldn't do it, so you could check out other libraries that do binary over WebSockets.

Blacksnake answered 23/10, 2012 at 0:54 Comment(2)
This seems like what I as looking for, thanks a lot for suggesting about the WebSockets. I guess I should go with it.Crossroads
Yeah, after some research, I am settling for node.js the best way.Crossroads
I
2

Is there any specific reason why you cannot run a server on your windows machine? 60kb/seconds, looks like some kind of an embedded device?

Based on our description, you ned to show image information, in realtime on a browser. You can possibly use HTTP. but its stateless, meaning once the information is transferred, you lose the connection. You client needs to poll the C++/Windows machine. If you are prety confident the information generated is periodic, you can use this approach. This requires a server, so only if a yes to my first question

A chat protocol. Something like a Jabber client running on your client, and a Jabber server on your C++/Windows machine. Chat protocols allow almost realtime

Ingredient answered 22/10, 2012 at 6:20 Comment(1)
Thanks a lot for responding. Yes, I am able to run a C++/Windows server. That's not a problem and yes that's correct, the clients are embedded machines. The information generated is periodic, but I shouldn't miss any packet since I am using differential encoding. I'll do some research on Jabber.Crossroads
E
2

While it may seem to make sense, I wouldn't use MSMQ in this scenario. You may not run into a problem now, but MSMQ messages are limited in size and you may eventually hit a wall because of this.

I would use TCP for this application, TCP is built with reliability in mind and you can simply feed data through a socket. You may have to figure out a very simple protocol yourself but it should be the best choice.

Unless you are using an embedded device that understands MSMQ out of the box, your best bet to use MSMQ would be to use a proxy and you are then still forced to play with TCP and possibly HTTP.

I do home automation that includes security cameras on my personal time and I use the .net micro framework and even if it did have MSMQ capabilities I still wouldn't use it.

I recommend that you look into MJPEG (Motion JPEG) which sounds exactly like what you would like to do.

http://www.codeproject.com/Articles/371955/Motion-JPEG-Streaming-Server

Eat answered 22/10, 2012 at 21:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.