Connecting an external program to a unity server

Hi,

I need to connect a windows forms app to a unity server to retrieve and display data. (Just a little bit of data) I looked around on the unity forums but this doesn’t seem possible with unitys networking. I was trying to include the unity DLL and use the networkview and RPC calls.
If this is in any way possible could someone point me in the right direction?
If this isn’t possible I think I’ll use .NET tcpclient and tcplistener, but I don’t knoz if unity plays nice with those.
Maybe someone here has another suggestion?

You should use “normal” sockets like you already mentioned. The builtin networking is based on Raknet but the version could change in later versions. It’s only meant to create connections between Unity applications.

Including the UnityEngine.dll won’t help much since it’s just a wrapper-dll for the scripting engine. Most of it’s functions are directly mapped to the native c++ functions which are part of the Unityplayer (which IS actual the Unity engine).

There should be no problem to start your own tcp sockets along with Unity-networking as long as you use different ports :wink:

I ended up writing my own RPC system over .NET TCP, thanks for the answer!

Hello! So happy to know you by seeing your post “Connecting an external program to a unity server”. In my project, I also need to connect a windows forms app to a unity server to send commond. But I met following problems:

I found that the network function in unity can not work here, so I chose .Net TcpClient/ TcpServer. It worked, but when I loaded another scene, it stoped until I closed unity in task manager of windows. Do you met this situation before?If so, is it means that Using .Net Network function is not a good way for my program?

Then I try to program with Socket. It worked fine when loading new scene. But I found after connecting with server, the windows forms app cannot send massage successfully. The code that receive data in unity was started in a new thread and run in when(true). Is it a right way to wait the data? or Is there any better way to do that?

Please give me some advice if it is convenint. I will give you my code when I am in my work place. Hope to discuss with you about programming in Unity.

I’m looking forward for your reply

Thank you very much!