code: def open(self):
          
          self.device = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          self.device.connect((self.host, self.port))
  
          if self.device is None:
              print "Could not open socket for %s" % self.host
docs: Open TCP socket and set it as escpos device