Add the error if the producer could not connect to the server.
This commit is contained in:
@@ -36,8 +36,12 @@ class ProducerClient:
|
||||
self.writer = None
|
||||
|
||||
async def connect(self):
|
||||
self.reader, self.writer = await asyncio.open_connection(self.__ip, self.__port)
|
||||
self.console.print(f'[yellow b][INFO][/] Connected to the server ({self.__ip}:{self.__port}).')
|
||||
try:
|
||||
self.reader, self.writer = await asyncio.open_connection(self.__ip, self.__port)
|
||||
self.console.print(f'[yellow b][INFO][/] Connected to the server ({self.__ip}:{self.__port}).')
|
||||
except ConnectionRefusedError:
|
||||
sys.stderr.write("Could not connect to the server. Please, check the ip and the port.\n")
|
||||
sys.exit(1)
|
||||
|
||||
async def send(self, message: str):
|
||||
self.writer.write(struct.pack('<L', len(message)))
|
||||
|
||||
Reference in New Issue
Block a user