Search Unity

  1. We have added sub-forums for the experimental MLAPI and Unity Transport Package. Please use the new forums to discuss related topics.
    Dismiss Notice

How to create multiplayer Server TCP

Discussion in 'Multiplayer' started by Dmidecode, May 31, 2021.

  1. Dmidecode

    Dmidecode

    Joined:
    Jan 20, 2014
    Posts:
    3
    Hello Everybody,

    I wanted to create a new multiplayer game and I have just a basic theoric knowledge on how work multiplayer.
    I have search on the forum and some tutorials how to create a TCP server with Unity but I don't find anything I want.
    I see there is a lot a UDP tutorial but I just want to have a basic server which will receive a message and anwser another message.
    Does Unity provide something to do that or do I need to have a .netCore Api beside ?
    I am sorry if this post is a duplicate.

    Have a good day
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,229
    Unity supports the regular C# Socket class. Any C# TCP server using the Socket class will work. Just launch it on a separate thread. I find ConcurrentQueue is useful for communication between networking threads and the main thread.
     
  3. Dmidecode

    Dmidecode

    Joined:
    Jan 20, 2014
    Posts:
    3
    Thank you very much for your answer !
    I found some useful ressources about Aws Services (Api Gateway / Lambda / Dynamo DB) to have a web socket server and Unity to communicate between those.
    I will check what you said.
    Have a good day :)
     
  4. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,878
    You can check out Telepathy, it's the best scaling approach to managed TCP in Unity as far as I know.
    Async / SocketAsyncEventArgs performs way better outside of Unity, but in Unity it doesn't.
     
  5. Dmidecode

    Dmidecode

    Joined:
    Jan 20, 2014
    Posts:
    3
    Thank you @vis2k ! It looks wonderful.
    So if I want to implement Telepathy, server side: I must create a scene in Unity with no camera and only gameobject which will have network script on them or is there another way ?
     
unityunity