code: def open(self):
          
          self.device = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          self.device.settimeout(self.timeout)
          self.device.connect((self.host, self.port))
  
          if self.device is None:
              print("Could not open socket for {0}".format(self.host))
docs: Open TCP socket with ``socket``-library and set it as escpos device