I want to deliver a huge amount of data around 30 times each second from a C# application to my Unity Application. Since mapped memory and pipes aren't supported in Unity i thought about a tcp socket. Would this be fast enough if the communication is in the scope of one machine only?
Shared memory is the fastest form of interprocess communication. The main advantage of shared memory is that the copying of message data is eliminated. The usual mechanism for synchronizing shared memory access is semaphores.
Our experiments re- veal that shared memory provides the lowest latency and highest throughput, followed by kernel pipes and lastly, TCP/IP sockets.
Two-way communication between processes can be achieved by using two pipes in opposite "directions". A pipe that is treated like a file. Instead of using standard input and output as with an anonymous pipe, processes write to and read from a named pipe, as if it were a regular file.
The language that's used in Unity is called C# (pronounced C-sharp). All the languages that Unity operates with are object-oriented scripting languages. Like any language, scripting languages have syntax, or parts of speech, and the primary parts are called variables, functions, and classes.
Possibly as of 2017, Unity also supports Managed plug-ins.
Unity3D supports c++ too.
Native plugins are platform-specific native code libraries. They can access features like OS calls and third-party code libraries that would otherwise not be available to Unity. However, these libraries are not accessible to Unity’s tools in the way that managed libraries are. For example, if you forget to add a managed plugin file to the project, you will get standard compiler error messages. If you do the same with a native plugin, you will only see an error report when you try to run the project. More...
...and:
Unity has extensive support for native Plugins, which are libraries of native code written in C, C++, Objective-C, etc. Plugins allow your game code (written in Javascript or C#) to call functions from these libraries. This feature allows Unity to integrate with middleware libraries or existing C/C++ game code. More....
With c++ code you are free to do anything you want including writing a native name pipe server through which your c# app could send data to.
Local named pipes are incredibly fast because they run in Kernel mode and don't go through the network layer unlike TCP which does.
I would recommend named pipes over TCP if comms is for local machine only.
Alternatives to named pipes are:
Tell me more...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With