Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Unity vs IPC?

Discussion in 'Multiplayer' started by johnny_littlepunch, Aug 27, 2021.

  1. johnny_littlepunch

    johnny_littlepunch

    Joined:
    Apr 23, 2021
    Posts:
    14
    Hi. I need to communicate with other processes (on local computer, Win 10 standalonе) from Unity scripts. For example, using anonymous pipes. But... working examples from MS documentation don't work under Unity in my tries - exceptions like "not implemened", "not authorized" etc., etc., etc. (running under administrator). What is working way to do IPC under Unity?
     
  2. johnny_littlepunch

    johnny_littlepunch

    Joined:
    Apr 23, 2021
    Posts:
    14
    Have investigated use of named pipes on local computer as well. In this case, simply: "The system cannot find the file specified" - it means named pipe. Examples with VS are working fine though. This is so strange... My scripts are in attachment, they are supposed to be used in OpenXR app.
     

    Attached Files:

  3. johnny_littlepunch

    johnny_littlepunch

    Joined:
    Apr 23, 2021
    Posts:
    14
    Unity Technologies, what do you recommend? Should I use some other mechanisms instead of named pipes, e.g. disk files or sockets?
     
    PrimePeter likes this.
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
  5. johnny_littlepunch

    johnny_littlepunch

    Joined:
    Apr 23, 2021
    Posts:
    14
    Very interesting thread and solution by CodeMankeyYT. In my sources above, the server stream is implemented in the console app, and the client stream - in the Unity app. So I don't get "Not implemented" exception, but have "The system cannot find the file specified" instead )) This does not depend on computer architecture - I tried it. Maybe it depends on the Unity version, but I don't want to downgrade (from 2020.3.17f). The solution, offered by CodeMankey depend on tricky choice of "right" parameters - this is week side of it, although I like it. Now, I am preparing a solution that will not have such dependency. If it flies, I will share it. In any case, thank you very much for the information!
     
    PrimePeter and Joe-Censored like this.
  6. johnny_littlepunch

    johnny_littlepunch

    Joined:
    Apr 23, 2021
    Posts:
    14
    Hi. The error in my sources as of Aug 28, 2021 (see above) is lack of sleep time for pipe communication. When I added these periods - all exceptions disappeared, message from the server was sent and received successfully by the client. Sources for working example are attached. Thanks again to Joe-Censored.
     

    Attached Files:

    Last edited: Sep 5, 2021
  7. johnny_littlepunch

    johnny_littlepunch

    Joined:
    Apr 23, 2021
    Posts:
    14
    In addition. In my case, the best way to implement interprocess communication turned out to be using of the MemoryMappedFile and Mutex classes. Mono and .Net implementations really do work without any problem and Microsoft documentation contains clear examples.
     
    PrimePeter likes this.