I make a bot in python, it should respond to messages from the server, that is, something like this algorithm
- We go about our business ..
- If the message arrived we process ..
- We are engaged further in the affairs
The code is implemented as a class.
class Spider: def connect(self, host, port): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect((host, port)) def run(self): while (1): if self.sock.recv(1024): # Как сделать что бы он не ждал пока придет? #принимаем команду и обрабатываем