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 /
avatar image
0
Question by ghiasirad · Mar 12, 2018 at 02:55 PM · unity 5connectiontcp

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?

Comment
Add comment · Show 1
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 TreyH · Mar 12, 2018 at 03:02 PM 0
Share

It's not a tutorial from Unity, but this is a tutorial on setting up a chat server within Unity using a TCP connection.

https://www.youtube.com/watch?v=7_BCbzR$$anonymous$$i2w

2 Replies

· Add your reply
  • Sort: 
avatar image
0

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:

https://www.youtube.com/watch?v=7_BCbzRMi2w

https://www.youtube.com/watch?v=WBYRTlaUSsk

Comment
Add comment · Share
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
0

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.


script.zip (7.1 kB)
Comment
Add comment · Show 2 · Share
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 Summit_Peak · Mar 24, 2018 at 07:11 PM 0
Share

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.

avatar image ghiasirad · Mar 26, 2018 at 06:56 PM 0
Share

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

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

152 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


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