Reputation: 1
I've developed an application in C# that handles TCP/IP connections and after running some diagnostics, I concluded that compiling and runtime can be improved. I decided to rewrite the entire program in C++ since it also runs smoother in a Lunix envrionment.
Is there a way I can use C# libraries like Sockets, Net, and Net.IPAddress in C++?.
I did some research on this and found out I can call these libraries in C++ through: #using (shevron)System.dll> But I'm hesistant if it will cause overhead and problems in a Lunix envrionment.
Upvotes: 0
Views: 366
Reputation: 16026
As I said in my comment, there is Mono documentation about using C# libraries from native code, cf. the link in the comment, http://www.mono-project.com/docs/advanced/embedding/. The native program basically embeds the Mono runtime for that.
Hans Passant made the valid objection that the #using
directive in your C++ code indicates that your "C++" code is actually the Microsoft proprietary C++/CLI which will not compile under Linux. How much work it would be to port that depends strongly on how many non-C++ features you used. The interop with Mono will also be more complicated than calling the C# functions in the Microsoft ecosystem.
If you look at performance my gut feeling is that the performance of network-heavy code will be dominated by the networking. Wasting a few CPU cycles should not be an issue, unless you are targeting an embedded system. On a PC, running in Mono or native may not make much of a difference. But this also depends a lot on the actual application (more communication or more computation?).
Upvotes: 1