- Home /
Unity TCP Connection
Hello. I am new to unity. I have done some jobs in it, but I cannot say I am proficient in it. Is there any tutorial on how I can connect my project using a TCP connection to receive probabily Double data from another program or server?
It's not a tutorial from Unity, but this is a tutorial on setting up a chat server within Unity using a TCP connection.
Answer by Summit_Peak · Mar 12, 2018 at 03:42 PM
System.Net.Sockets are supported in unity, so you can use TcpClient and TcpListener. Remember to use .NET 2.0 rather than .Net 2.0 Subset: File->Build Settings->Player Settings->Other Settings->Api Compatibility Level->.Net 2.0
Here are some tutorials for more information:
Answer by ghiasirad · Mar 24, 2018 at 04:55 PM
Thanks a lot for these helpful comments. In the past days I was implementing it. There is still a problem. My Update function in Client does not the job. Although I have written the codes precisely the same, the Update function in Client does not do it to get "Server : Guest has connected." I do not know what is the problem. Is it because of the Broadcast function of the Update. It goes to Broadcast, and I expect to do the writer part, but nothing is going back. I use print function and I see that it is inside this function. I would be glad if you help me. I have attached the Server and Client scripts in a zip file for your considerationlink text. Thanks.
I glanced through your code and didn't see any glaring problems. I would suggest testing the code on another platform outside of Unity, such as Visual Studio or something. Once it works on the other platform, you can track down any problems and get it working in Unity. If it still doesn't work in Unity, you may have the option to set up Unity to communicate with the working code on the other platform. I was forced to use that option on a previous project, since that version of $$anonymous$$ono.Net didn't have full supports for pipes.
Just fixed it. Thought this fact that there was no check box besides my Client script found that there should be a problem in one of my per-frame methods. In this case, ins$$anonymous$$d of "Update()", I had "update()" with lower case "u". It was a good hint to me to be more careful in the future that Unity is really sensitive to this issues.
Thanks again for the help.
Your answer
Follow this Question
Related Questions
How to change SetChannelOption for existing connection? 0 Answers
UNet NetworkServer max connections 4 Answers
cannot connect asset store via unity editor ( it is just loading) 0 Answers
How to connect to a match by a string 0 Answers
How to connect Unity object with Beagebone Black board? 0 Answers