Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by anfrolkin · Aug 21, 2015 at 02:09 PM · unity 5pipe

Pipe problem for interconnection between unity 5.1 and third app

Hi

I am trying to use named pipes in Unity to pass data to and from another application. I made test Pipe Server in VS2012

static void Main(string[] args) { CreatingPipeServerLoop(); }

 const byte sentServerValue = 1;
 const byte sentClientValue = 2;

     static public void CreatingPipeServerLoop()
     {
         while (true)
         {
            Thread.Sleep(500);
             
             using (NamedPipeServerStream pipeServer =
                 new NamedPipeServerStream("pipetest", PipeDirection.InOut))
             {
                 pipeServer.WaitForConnection();

                 Console.WriteLine("Client connected.");
                 try
                 {
                     byte answer = (byte)pipeServer.ReadByte();

                     pipeServer.WriteByte(sentServerValue);
                     pipeServer.Flush();
                 }

                 catch (Exception e)
                 {
                     Console.WriteLine("ERROR: {0}", e.Message);
                 }
             }
         }
     } 

And I made Pipe Client in Unity3d 5.1.2f1 :

 void Start () {

     System.Threading.Thread pipeThread = new System.Threading.Thread(delegate() { CreatingPipeClientLoop(); });
     pipeThread.Start();
 
 }
 
 // Update is called once per frame
 void Update () {
 
 }

 const byte sentServerValue = 1;
 const byte sentClientValue = 2;

 public void CreatingPipeClientLoop()
 {
     for (int i = 0; i < 100000; i++)
     {
         //byte respByte = 0;// MainBaseErrorExcess;
         using (NamedPipeClientStream pipeClient =
                new NamedPipeClientStream("pipetest"))
         {
             
             try
             {
                 pipeClient.Connect();
                 //Console.WriteLine("Server connected.");
                 
                 pipeClient.WriteByte(sentClientValue);
                 pipeClient.Flush();
                 byte respByte = (byte)pipeClient.ReadByte();
             }
             
             catch (System.Exception e)
             {
                 //Console.WriteLine("ERROR: {0}", e.Message);
             }
         }
     }
 }

I started Server and then Client in Unity3d 5.1.2f1. Server connected 1-2 times then Unity crashed. Some times pipeClient threw exception "The operation completed successfully". I launched this test project on 5 PC with Windows 7 (64 bit) every time Unity crashed. It worked only on PC with Windows 7 (32 bit) and Windows 7 on Mac. Also it worked in Unity 4.5, befor I updated Unity I did not know about the problem. How to implement exchange between Unity and another application?

Regards, Anatoly Frolkin.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image anfrolkin · Aug 21, 2015 at 02:00 PM 0
Share

Function CreatingPipeServerLoop() is used in VS2012 console application just for test. It has endless loop and it called once in function $$anonymous$$ain(). In general program I dont use such loop. Function CreatingPipeClientLoop() is used in Unity, it does not have endless loop. It finishes when OnDisable() executes.

avatar image anfrolkin · Aug 21, 2015 at 02:50 PM 0
Share

I change code "while(loop)" to "for (int i = 0; i < 100000; i++)" but Unity still crashed after 1-10 connections with Server App. Anyway thank you VesuvianPrime, I dont know about one thread.

avatar image Nyxo · Jun 16, 2016 at 03:58 AM 0
Share

Did you ever manage to solve this problem? I believe I am encountering exactly this same problem, and I'm really not sure what I can do about it.

Further information I've found: Attaching VS to the Unity Editor when it crashes tells me "A heap has been corrupted". I've managed to trim out a bunch of code, to the point where I simply create the client and connect (ie. no writing to it, or flushing, or reading), and it still happens when I loop thru this repeatedly, after between 1 and 6 times or so. Seems to be random, which makes sense with corrupted heaps.

avatar image anfrolkin · Jun 16, 2016 at 05:51 PM 0
Share

I do not use pipes. I use sockets, I don't have any problem with sockets.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

UTF8 string acquired through NAMEDPIPES unrecognized by Unityengine 2 Answers

Cannot drag text object into inspector 2 Answers

Root motion deforms model on certain animations 0 Answers

custom object in place of leap hands controller . 0 Answers

Compact Wordle Graphics in Unity3D 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges