• 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 rodeowild · Feb 17, 2017 at 09:15 AM · c#networkingnetworksocket

LLAPI vs. pure C#.NET sockets

I've been playing with unity's HLAPI a bit, and w$$anonymous$$le it does take care of a lot of the grunt work, it can be confusing at times and just plain too restrictive at others. So now i'm looking at the LLAPI and it just seems like a very t$$anonymous$$n layer on top of TCP sockets. Is there some advantage of using the LLAPI over C#.NET socket library (I can't see any but I was wondering what others t$$anonymous$$nk)?

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 RobAnthem · Feb 17, 2017 at 10:59 AM 0
Share

Honestly I'd go with the native .NET one. Basically unless there is a specific advantage you can pretty much assume .NET does everything as absolutely efficient as possible. After all it was made by the richest organization in the world... Microsoft. Unity tends to add unnecessary aspects to things to make it more "beginner friendly" Which after a while of coding in Unity, I am sure you have seen, or will see, a large portion of the main API isn't worth using. Even ScriptableObjects are only worth using due to the fact Unity will recompile them to match any changes to the instanced class. Which in the end, is still just an "ease of use" thing.

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by AurimasBlazulionis · Feb 17, 2017 at 12:57 PM

The problem with C# .NET will most likely be is performance. The LLAPI is written in C/C++ and is optimized for the usual use case. And no, LLAPI is not based on TCP. C# part should run on lower performance because most of the stuff happens in C# side and not C++ side.

Not to mention a new/upgraded LLAPI is being made w$$anonymous$$ch is able to handle loads of hundreds of megabytes per second.

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
1

Answer by WazzaM · Apr 14, 2017 at 05:48 AM

Joe is correct.

As an aside, you can use UDP from C# to roll your own protocol.

-Warwick

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 rodeowild · Feb 21, 2017 at 10:13 AM

Edit: I've done some research on my own. The LLAPI is really flexible, manages t$$anonymous$$ngs you may not want or know how to manage in unity (threads, etc). I've also looked under the hood at the HLAPI (w$$anonymous$$ch you can download here). I found it to be a jungle of odd commands and assumed use cases. I'm sure it has uses, and it may be necessary if you're very green, but writing your own classes using the LLAPI, seems easier than, say, learning all about how the NetworkManager interacts with the NetworkIdentity, or figuring out the subtle differences between the NetworkClient and the NetworkServer. As far as performance, it seems like the HLAPI is entirely built on the LLAPI (as the docs say, and of course as would be expected), so you should lose not$$anonymous$$ng by bypassing it and dealing directly with the LLAPI.

Of course, t$$anonymous$$s is a half-baked opinion, so if you find t$$anonymous$$s and disagree, please let me know :)

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 rodeowild · Apr 13, 2017 at 04:27 PM 0
Share

Ok so I've done more research on this topic. There are advantages and disadvantages to both protocols. Here they are:

  • speed - The LLAPI is built on UDP, so it will be almost definitely be faster than TCP, although some test data would be nice to look at. LLAPI wins here.

  • ease of use - unity makes it really easy to write networking code using the LLAPI (don't use the HLAPI - just DON'T). If you start writing a TCP client and server you start having to deal with concurrency, callbacks, asynchronous functions, and a bunch of other fun stuff. LLAPI is better for quick and easy development. Advantage: LLAPI.

  • Modularity - If you build your app using the LLAPI, you are basically stuck using it for the clients, server and any middleware. This is because you are using a Unity specific protocol. Nothing else will be able to decipher your messages. TCP allows for you to take a much more reasonable approach. TCP wins big here.

Basically, as with everything, it depends on what you want to accomplish. Quick and easy, go LLAPI. More robust, go TCP.

avatar image Joe-Censored rodeowild · Apr 13, 2017 at 11:49 PM 0
Share

For most multiplayer games using TCP would negatively affect the game. Not because of speed, but because each individual position update is rather trivial and would negatively affect the game to be resent if lost after receiving later position updates. UDP automatically handles this by just not resending anything automatically (Unity implements reliable channels as an option on top of this to do its own packet tracking and guaranteed delivery for when that is needed, for commands, rpc's, etc, but most data sent is usually object positions and those are only important at the time they are sent).

TCP though is a guaranteed delivery protocol. I would only use it for turn based games, card games, or similar slow paced games where the majority of packets are important to receive. I would never use it for any game with fast moving objects, or any game where object positions are being synced several times per seconds like UNET is really designed for.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Network call Method from Instants of Prefab 2 Answers

Command method dont change variables on server 0 Answers

NetworkManager.OnServerDisconnect not being called 2 Answers

Multiple Cars not working 1 Answer

C# Networking help? 1 Answer


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