Ejemplo n.º 1
0
void MyThread::run(){
    LogReader logreader;
    LogSender logsender;
    list<MatchedLogRec> matches=
    logreader.readLogs();
    /*准备发送数据*/
    logsender.initNetWork();
    char datastr[100]={0};
    /*循环发送数据*/
    while(matches.size()>0){
       sleep(1);
       bool f=logsender.sendMatche(*matches.begin());
      if(f){
          /*发射信号*/
          sprintf(datastr,"%s:%d:%s",matches.begin()->logname,
          matches.begin()->pid,matches.begin()->logip);
          emit  mySig(QString(datastr));
          /*删除这条数据*/
          matches.erase(matches.begin());
      }else{
          break;
      }
    }
    /*关闭fd*/
    logsender.saveSendFailed(&matches);
}
Ejemplo n.º 2
0
int main(){
    LogReader  logreader;
    LogSender  logsender;
    list<MatchedLogRec>  matches=
    logreader.readLogs();
    logsender.sendMatches(&matches);
}
Ejemplo n.º 3
0
void  MyThread::run(){
    /*把发送的数据 通知给界面*/ 
    LogReader   logreader;
    list<MatchedLogRec>  matches=logreader.readLogs();
    LogSender   logsender;
   // logsender.sendMatches(&matches);
    /*让界面显示具体发送了那些数据*/
    logsender.initNetWork();
    /*循环发送数据*/
    while(matches.size()>0){
         char  datastr[200]={0};
         if(!logsender.sendMatche(*(matches.begin()))){
              break; 
         }
         /*把发送成功的数据通知界面*/
         sprintf(datastr,"%s:%d:%s",matches.begin()->username,matches.begin()->pid,matches.begin()->logip); 
         emit   mySig(QString(datastr));    
         matches.erase(matches.begin()); 
         sleep(1);
    }    
   
}