Search Unity

Basic P2P Networking

Discussion in 'Multiplayer' started by nitishk, Apr 8, 2013.

  1. nitishk

    nitishk

    Joined:
    Mar 23, 2013
    Posts:
    10
    I am creating a 2 player game where the user will click play, the client will search for any servers and if one is found it will connect with it. As soon as a server gets a connection it unregister's itself from the MasterServer as to not receive any more connections. If a client clicks play and no servers are found within a certain time period, it will create one and wait for someone else to join and then unregister itself.

    The problem is my code only works when there is 1 server running and a client connects. Soon as they are both in a game and if I run another 2 instances of the game I cannot connect them with each other. Even if the two games that are running and are successfully connected and the server of the two has unregistered itself the 3rd client will try to connect to it and get the error "The system we attempted to connect to is not accepting new connections" and it will not create a server.

    Any help would greatly be appreciated!
    Thanks.
     
  2. DryTear

    DryTear

    Joined:
    Nov 30, 2012
    Posts:
    312
    can you please clearify and rephrase your questions. What does code doesnt do, and what have you tried to solve. But if i understood you, instead of unregistering use Network.InitializeServer(2, blablabla);

    your Initialization probably allows more than 2 connections, so in the Initialization make it 2