Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 aidinz · May 03, 2016 at 02:20 PM · networkingmultiplayersocketsockets

Multiplayer game using Sockets or Socket.IO? (without UNET or Photon)

Hi,

I'm making a simple multiplayer game with Unity and for the sake of simplicity and maximum control I want to user Sockets.

Game will connect 2 players and get their inputs and apply it on each other's game in real time.

My question is, should I use Socket.IO? Is it better for my use? Because I've Googled around and apparently everyone is using Socket.IO but I've read previously that sockets are just fine.

Also for the server I rather to be able to deploy on Linux machines and don't get tied to Windows.

Any help is appreciated.

Comment
Add comment
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

6 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Masoud_A · Oct 23, 2017 at 03:36 PM

Well, it depends!


1- Are you targeting Browsers or Standalone and mobile platforms?

SocketIO is a transport protocol on top of other transport protocols; it uses WebSocket mainly and if websocket isn't supported then uses long polling or other transport options like flash sockets as a fallback.

So if you're not targeting Browsers, you have sockets and you don't need fallback capabilities of Socket.IO.

Also SocketIO has its own communication protocol on top of tcp and websocket, and has some added capabilities like Broadcasting, Reconnecting, message namespacing (like chat rooms) which as you want simplicity and more control, probably you don't need SocketIO for them.


2- Is it a real-time game or turn-based?

If its real-time then milliseconds matter and for sake of performance and speed it’s better to use UDP sockets rather than TCP, and handle message delivery and connection check by yourself. As SocketIO uses TCP for communication maybe it’s not a good choice for high performance real-time games.


If you are interested in establishing UDP communications with C# Sockets in unity, I have developed a Unity package which has necessary classes for establishing UDP connections and some working examples here.

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 canbaran011 · Aug 16, 2018 at 10:04 AM 0
Share

same as 1- For $$anonymous$$obile platform. 2- Real -Time game but delay is not important . I am just trying to learn connections of it.

tcp or udp does not matter for me . thank you anyway. how can we build our socket io ?

avatar image dhruv_unity154 · Apr 20 at 10:14 AM 0
Share

Hello, @Masoud_A Thanks for your package. But I have one question.

I am working on a project where I already using photon for networking. Can I use your package for socket io listen? Is it compatible with Photon?

avatar image
0

Answer by Valentinon13 · Oct 29, 2016 at 05:05 PM

hi, i made my own server with socket io its running real smooth but i am struggling whit the camera !

but everything works real smooth !

so if its just 2 players its a go i made my server running on a Rasp pi its real nice !

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 AIon_unity · Oct 14, 2017 at 04:43 PM

yes sockets are solid, check this one out: http://www.yudiz.com/developers-guide-to-unity3d-mmo-with-node-js-using-socket-io/

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 saifuddinazhar · Sep 13, 2018 at 04:18 AM

Yes.. you can use this plugin https://assetstore.unity.com/packages/tools/network/socket-io-for-unity-21721. its free and powerfull, tested on unity editor and android platform. I don't know about other platform. You can run example server included (beep.js.zip) first and then you can run the example scene.

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 I5 · Sep 13, 2018 at 04:43 AM

I've found that Tomcat (on the server, using websockets) + HTTP Pro (on the client, deployed in Unity, found in the asset store) provides the best performance, and is the simplest, easiest and quickest to setup (if you're rolling your own server comms). In terms of the "best" performance, I measured milliseconds for packet transmission and message receipt to/from the client and server. Differences between IO an websockets was negligible (a few milliseconds) for plain text messages and HTTP Pro didn't slow things down at all, and it handles TLS and even IO I think. So, I'd go with a tried and well proven solution of websockets (Tomcat server, or Jetty, or a few others) and a 3rd party asset that will connect to your server and not hamstring you into one protocol. HTTP Pro has worked for me (not affiliated with them in any way, it's just saved me a lot of time).

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
  • 1
  • 2
  • ›

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

11 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

Related Questions

Can we use Unitys LLAPI to establish a socket connect with a server? 1 Answer

Unity networking tutorial? 6 Answers

C# TcpListener is reachable only from local 1 Answer

TCP responses are not receiving properly on client side. 1 Answer

TCP and Sockets in unity 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