(self, step)
u'''Server's input is stored in a ServerState object
u'''Server's input is stored in a ServerState object
u Server s input is stored in a ServerState object
def get_servers_input(self, step):
        u'''Server's input is stored in a ServerState object'''
        if not self.so: return
        sockdata= str()

        # print '******Step : ' + str(step)
        n_fail = 5 if step==0 else 2
        n_fail_org = n_fail
        while True:
            try:
                # Receive server data
                sockdata,addr= self.so.recvfrom(data_size)
                sockdata = sockdata.decode(u'utf-8')
            except socket.error as emsg:
                print(u'.'),
                print("Waiting for server data on %d.............." % self.port)

                print(u"Server count down : " + str(n_fail))
                if n_fail < 0:
                    # self.shutdown()
                    return -1
                    n_fail = n_fail_org

                n_fail -= 1

            if u'***identified***' in sockdata:
                print(u"Client connected on %d.............." % self.port)
                continue
            elif u'***shutdown***' in sockdata:
                print ((u"Server has stopped the race on %d. "+
                        u"You were in %d place.") %
                        (self.port,self.S.d[u'racePos']))
                self.shutdown()
                return
            elif u'***restart***' in sockdata:
                # What do I do here?
                print(u"Server has restarted the race on %d." % self.port)
                # I haven't actually caught the server doing this.
                self.shutdown()
                return
            elif not sockdata: # Empty?
                continue       # Try again.
            else:
                self.S.parse_server_str(sockdata)
                if self.debug:
                    sys.stderr.write(u"\x1b[2J\x1b[H") # Clear for steady output.
                    print(self.S)
                break
def get_servers_input ( self , step ) : if not self . so : return sockdata = str ( ) # print '******Step : ' + str(step) n_fail = 5 if step == 0 else 2 n_fail_org = n_fail while True : try : # Receive server data sockdata , addr = self . so . recvfrom ( data_size ) sockdata = sockdata . decode ( u'utf-8' ) except socket . error as emsg : print ( u'.' ) , print ( "Waiting for server data on %d.............." % self . port ) print ( u"Server count down : " + str ( n_fail ) ) if n_fail < 0 : # self.shutdown() return - 1 n_fail = n_fail_org n_fail -= 1 if u'***identified***' in sockdata : print ( u"Client connected on %d.............." % self . port ) continue elif u'***shutdown***' in sockdata : print ( ( u"Server has stopped the race on %d. " + u"You were in %d place." ) % ( self . port , self . S . d [ u'racePos' ] ) ) self . shutdown ( ) return elif u'***restart***' in sockdata : # What do I do here? print ( u"Server has restarted the race on %d." % self . port ) # I haven't actually caught the server doing this. self . shutdown ( ) return elif not sockdata : # Empty? continue # Try again. else : self . S . parse_server_str ( sockdata ) if self . debug : sys . stderr . write ( u"\x1b[2J\x1b[H" ) # Clear for steady output. print ( self . S ) break