Ejemplo n.º 1
0
global client
global address
global msg_length
global seq_num

s          = None
client     = None
address    = None
msg_length = None
    
# Main server processing
while True:
    # Initialize and start server listening for clients
    seq_num = 0
    buf = ""
    if srv.is_srv_online() is not True:  
        s = srv.start_server(IP_ADDR, PORT)
        client, address = srv.client_connect(s)
    
    # Handle messages
    while True:
        try:
            # Receive data byte by byte and add to buffer
            msg_length = len(buf)
            #t0 = time.clock()
            data = srv.recv_msg(client, msg_length)
            if not data:
                raise ConnectionError('SERVER ERROR: Client is not connected! Attempting to reconnect...')
            buf += data
            while True:
                if srv.init_msg(buf) is True:
Ejemplo n.º 2
0
 def initClient(self):
     self.seq_num = 1
     if srv.is_srv_online() is not True:  
         self.s = srv.start_server(self.ip_addr, self.port)
         self.client, self.address = srv.client_connect(self.s)