kurifu
kurifu

Reputation: 153

Best Way to Send Data from C++ program to Rails Server

I have a C++ program that is constantly generating a large amount of data that needs to be sent to a Rails server. Both the program and the server are on the same machine running Suse Linux.

What is the most efficient and simple solution for this?

Upvotes: 1

Views: 313

Answers (3)

Alex Kremer
Alex Kremer

Reputation: 2321

Sockets are the way to go. If you want some good asynchronous and cross-platform sockets in C++ your best bet, probably, will be boost::asio.

Upvotes: 1

Jason
Jason

Reputation: 32520

You could use sockets since both your programs are residing on the same local machine, and in general it should be pretty straight-forward to send the serialized data over a local socket. Since the socket is using an internal buffer, the transfer time should be very fast. Your C++ program can either push data to the Rails server, or you can have the Rails server poll the C++ program providing you're setting up a cache in your C++ program to store the data in between polling calls. The push method would probably work best though.

Upvotes: 1

apneadiving
apneadiving

Reputation: 115541

You could store the data the way you want (file or database).

The only tough point is to make your Rails app aware the C++ program is completed.
I'd strongly advise you to store this information in cache so that it won't cost much to check this every period you need.

Upvotes: 1

Related Questions