Networking interupts running each other over

PROBLEM FIXED!! THANKS ALL.

The problem is that the client code never makes it to here: print “Made it to” , without the big for loop in the server code. Any ideas how this problem should really be fixed?
Thanks all.

Some more explanation of the problem.
The server code sends out 2 packets of info.
self.server.sendData({PACKETTYPE: FIRSTPACKET, SENDER: SERVER, RECEIVER: id, PLAYERID: id}, con)
self.server.broadcastData(startPacket)
The first packet goes only to the client that is connecting
The second goes to all the clients including the one that is connecting.
The for loop is a wait pause between the 2 packets being sent to give the client time to finish working on the first packed. With the pause client and server work.

BUT, that is not ideal. What needs fixing is the client. It should be able to handle the 2 packets coming in. After this set of code before the client code is more info.

# SERVER CODE (next is the client)
  def printConnected(self, con, count, address):
        # Make a new unique ID
        while True:
            id = randint(-2147483648, 214748364)
            if id not in self.idList : break
        print "connect event, id, idList", id, self.idList, address
        #send out server time and clients new id so that client can syc with it.
        self.server.sendData({PACKETTYPE: FIRSTPACKET, SENDER: SERVER, RECEIVER: id, PLAYERID: id}, con) # goes only to the con that started the connection
        self.users.addUser(con, id) # make a class instance of user, id, con and other user info
        self.conDict[con] = id # make a dictionary of IDs and Cons
        # send list of all the other player's IDs
        self.idList.append(id)
        print "Pausing",
        for i in range(1,1000): print "pausing more", # This is a really stupid fix so that the client does not recieve 2 packets together while trying to set up.
        startPacket = {}
        startPacket[PACKETTYPE] = STARTPLAYERS
        startPacket[SENDER] = SERVER
        startPacket[RECEIVER] = id
        startPacket[PLAYERID] = id
        startPacket[PACKETS] = self.idList
        self.server.broadcastData(startPacket) # goes to everyone that is connected.

The client starts setting up shop. It sends a message to the Server and gets a time sync.

CLIENT CODE

    def startNetwork(self):
        self.connect()
        self.startPolling()
        # wait for the  client id.
        waitTime = globalClock.getRealTime() + 10 # wait for ten seconds
        print 'Waiting For Server'
        while False == self.cReader.dataAvailable() :
            base.graphicsEngine.renderFrame()

            if waitTime < globalClock.getRealTime() :
                print 'Stuck waiting, surver must be down.'
                return False

        while self.cReader.dataAvailable():
            datagram = NetDatagram()  # catch the incoming data in this instance
            # Check the return value; if we were threaded, someone else could have
            # snagged this data before we did
            if self.cReader.getData(datagram):
                packet = self.processData(datagram)
                print 'inner reader', packet
                if packet[PACKETTYPE] == FIRSTPACKET : # type(packet)  is dict :
                    self.ID = packet[PLAYERID]
                    print 'Player ID', self.ID
                    self.startDataPolling()
                    return True
                else :
                    print 'Start ID error!'
                    return False
        print "88 Error!" # Should never makes it here.
       
        return True

[/code]

You should use an event driven architecture. Basically your client and your server should be one huge switch statement.

en.wikipedia.org/wiki/Event-driven_architecture

Pausing the server or the client in order for network packets to sync is is terrible.