Search Unity

Unity cant have multiple servers hosting at once on Linux

Discussion in 'Multiplayer' started by jayslayer, May 24, 2018.

  1. jayslayer

    jayslayer

    Joined:
    Jul 21, 2013
    Posts:
    1
    So i have a master server on Linux and when a player requests a lobby it starts a server host to have that player and anyone who wants to connect to him play the game. the server manager calls lobbyManager.StartHost() and the server host calls lobbyManager.StartServer(). on Linux i start the server manager and everything works fine but when i start the server host while the server manager is still running it gives me this error:
    Code (CSharp):
    1. Unhandled exeption: System.Net.Sockets.SocketExeption: Address already in use at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00000] in :0 at System.Net.Sockets.TcpListener.Start (Int32 backlog) [0x00000] in :0 at System.Net.Sockets.TcpListener.Start () [0x00000] in :0 at GameStartedServer.BackgroundStart () [0x00000] in :0
    I don't have this problem on windows only on Linux so i looked around and found this it says that its a problem with Linux and a work around they found was to do
    Code (CSharp):
    1. server.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true)
    before starting the server. but what i need help with is i need to know how to call that function in unity. Because all i do is call StartServer or StartHost i don't have access to the socket so i cant call SetSocketOption