Reputation: 2067
I am to write a cross platform program for windows and linux :: A Java program will send data to a tcp/ip port and there will be a C/C++ program which will continuously listen from that tcp/ip port when it gets some data it will do some works and send the result data to another tcp/ip port from which now the Java program will read the data and do some actions. I am more worried about the C/C++ portion. Can you please help with any detail or useful link or sample code ?
Upvotes: 3
Views: 3709
Reputation:
My suggestion: boost::asio for C++ cross platform networking and google protocol buffers for specifying the cross platform/cross language protocol.
Use boost::asio for sending/receiving bytes of data and google protocol buffers to turn those bytes into something useful(ints, strings, etc).
Upvotes: 2
Reputation:
There are tons of networking APIs/libraries and event notifications mechanisms. Since I assume you are new to C++ and don't really want to deal with platform-specific functionality in order to squeeze microseconds from your implementation and/or write different code for different platforms, I think your best bet is to use Boost ASIO - a cross-platform C++ library for network and low-level I/O programming. It has a very good documentation, tons of examples, and is pretty easy to use in general. It will work on many platforms w/o a need to change a single line of code in your application. It has its pitfalls, but they are not very significant unless you are doing something extremely complicated that has a lot of strict requirements for performance, memory usage, latency, throughput or all of the above.
Just in case I am not right in my assumptions, there are a lot of alternatives. Some of them are:
Good luck!
Upvotes: 0