Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Discussion Most stripped down C# TCP / UDP networking solution? (similar to Lidgren)

Discussion in 'Multiplayer' started by AstralProjection, Aug 29, 2022.

  1. AstralProjection

    AstralProjection

    Joined:
    Feb 12, 2013
    Posts:
    11
    Looking for a C# networking library with nothing integrated into Unity. Or it can have integration but not require it. Was using Lidgren Network but it is no longer updated.

    All we need is:

    - spin up client / server
    - connect, disconnect, some error check
    - send custom payload messages as reliable or unreliable
    - NAT punch would be nice (if that's still a big issue)
    - Windows platform

    All the client prediction, matchmaking, etc. is already a solved issue and not needed. Do not want anything that requires building per-object RPCs or flagging game object variables for replication.

    Can any of the existing popular networking solutions be used this way? Like Photon or Fishnet? Can I spin up a server in client in those and send arbitrary payload messages? If I can spin up a client and server in a C# console program without Unity even running that is the right direction ...
     
  2. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,334
    Sounds like you are looking for a low level transport.

    For UDP, the most used are probably enet, litenetlib, kcp.
    We actually ported kcp to C# after having scaling issues with enet/litenetlib.

    For TCP, we also had to make our own transport due to lack of existing TCP transports.

    The above are all MIT licensed, so it's safe to use in your project :)
     
    CodeRonnie and AstralProjection like this.
  3. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    338
    Maybe LiteNetLibManager? It's easy to use and I'm fairly sure checks these boxes. It is based on LiteNetLib.

    I disagree with the scaling issues comment. We use it and have tested thousands of CCU without issue. SURIYUN also uses it for scaling, and they're a very well rated asset developer.

    The headers are also extremely small in LiteNetLib, significantly less than KCP, using only 12% the bandwidth for reliable messages!

    LiteNetLibManager is MIT and created by individuals that have already created many 'transports' in the past. There are recent updates on the git as well.
    https://github.com/insthync/LiteNetLibManager
     
    Last edited: Aug 30, 2022
    AstralProjection likes this.
  4. AstralProjection

    AstralProjection

    Joined:
    Feb 12, 2013
    Posts:
    11
    That looks promising. Thanks. :)
     
  5. AstralProjection

    AstralProjection

    Joined:
    Feb 12, 2013
    Posts:
    11
    Thanks. Look pretty good. Scaling isn't a huge issue since our game is 4-8 player coop.
     
    Punfish likes this.
  6. AgentFire

    AgentFire

    Joined:
    Jul 19, 2014
    Posts:
    5
  7. qbvbsite

    qbvbsite

    Joined:
    Feb 19, 2013
    Posts:
    83
    I use LiteNetLib (https://github.com/RevenantX/LiteNetLib) and have had 0 issues with it. Pretty easy to integrate in away that you can abstract it out so if you did run into issues it can be easily replaced.
     
    Punfish likes this.
  8. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    338
    As someone which is utilizing LiteNetLib in a framework used by tens of thousands, and I know I said this in the past, but it deserves a really big +1 from me.