- Home /
 
 
               Question by 
               Irishbruse · Jan 24, 2016 at 04:07 PM · 
                c#networking  
              
 
              Why do i get this error in my muiltiplayer Game
This is my code below
 using UnityEngine;
 using System.Collections;
 using UnityEngine.Networking;
 using UnityEngine.UI;
 
 public class NetworkManager_Custom : NetworkManager {
 
 
     public void StartupHost()
     {
         SetPort();
         NetworkManager.singleton.StartHost();
     }
 
     public void JoinGame()
     {
         SetIPAddress();
         SetPort();
         NetworkManager.singleton.StartClient();
     }
 
     void SetIPAddress()
     {
         string ipAddress = GameObject.Find("InputFieldIPAddress").transform.FindChild("Text").GetComponent<Text>().text;
         NetworkManager.singleton.networkAddress = ipAddress;
     }
 
     void SetPort()
     {
         NetworkManager.singleton.networkPort = 7777;
     }
 
     void OnLevelWasLoaded(int level)
     {
         if (level == 0)
         {
             //SetupMenuSceneButtons();
             StartCoroutine(SetupMenuSceneButtons());
         }
 
         else
         {
             SetupOtherSceneButtons();
         }
     }
 
     IEnumerator SetupMenuSceneButtons()
     {
         yield return new WaitForSeconds(0.3f);
         GameObject.Find("ButtonStartHost").GetComponent<Button>().onClick.RemoveAllListeners();
         GameObject.Find("ButtonStartHost").GetComponent<Button>().onClick.AddListener(StartupHost);
 
         GameObject.Find("ButtonJoinGame").GetComponent<Button>().onClick.RemoveAllListeners();
         GameObject.Find("ButtonJoinGame").GetComponent<Button>().onClick.AddListener(JoinGame);
     }
 
     void SetupOtherSceneButtons()
     {
         GameObject.Find("ButtonDisconnect").GetComponent<Button>().onClick.RemoveAllListeners();
         GameObject.Find("ButtonDisconnect").GetComponent<Button>().onClick.AddListener(NetworkManager.singleton.StopHost);
     }
 
 
 }
 
 
 
               and this is the error that i get
 Cannot open socket on ip {*} and port {7777}; check please your network, most probably port has been already occupied
 UnityEngine.Networking.NetworkManager:StartHost()
 NetworkManager_Custom:StartupHost() (at Assets/Scripts/Networking/NetworkManager_Custom.cs:12)
 UnityEngine.EventSystems.EventSystem:Update()
 
               all help is appreciated
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by abhishek_hingorani · Jul 18, 2016 at 06:24 PM
I had the same problem, just add  NetworkServer.Reset();  before NetworkManager.singleton.StartHost();.
Cheers! @IrishBruse
Answer by JesusChrist17 · Jun 15, 2017 at 07:34 PM
i know that error is when you try to create other server but you already have created 1 with the same port. Does anybody know how to capture this error?
Your answer
 
             Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
UNET Health isn't syncing 1 Answer
C# How to have a toggle 1 Answer