code: def publish(self, topic, payload = None, qos = 0, retain = False):
          
          #print "PUBLISHING (",topic,"): ", payload
          payloadlen = len(payload)
          if topic is None or qos < 0 or qos > 2:
              print "PUBLISH:err inval"
              return NC.ERR_INVAL
          
          #payloadlen <= 250MB
          if payloadlen > (250 * 1024 * 1204):
              self.logger.error("PUBLISH:err payload len:%d", payloadlen)
              return NC.ERR_PAYLOAD_SIZE
          
          #wildcard check : TODO
          mid = self.mid_generate()
          
          if qos in (0,1,2):
              return self.send_publish(mid, topic, payload, qos, retain, False)
  
          else:
              self.logger.error("Unsupport QoS= %d", qos)
      
          return NC.ERR_NOT_SUPPORTED
docs: Publish some payload to server.