55555

#if 1
#include <stdio.h>  
#include <stdlib.h>  
#include "curl.h"  
#include <string.h>  
#include <pthread.h>  
#include <windows.h>  
#include <algorithm>  
#include <numeric>  
#include <vector>  
#include "Initialize.h"
#include <iostream>   

  
//#define MAX_THREAD 30//总发送次数  
int RecNum = 0;//成功接收到得次数  

LARGE_INTEGER m_nFreq;  
LARGE_INTEGER m_nCurrentUsTime;  


pthread_mutex_t mutex;//定义线程锁  
  
std::vector<double> m_PacketUseTime;//收到包消耗的时间  
  
//配置文件参数结构体   
extern struct ConfigValue configvalues;   
  
struct HttpStatistics   //计时   
{  
    double requestTime;  
    double responseTime;   
};  
  
struct HttpGetParam //参数  
{  
    char *url;  
    struct HttpStatistics httpStatistics;  
};  
  
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *param)  
{  
    return size * nmemb;  
}  
  
  
static size_t head_data(void *ptr, size_t size, size_t nmemb, void *param)  
{  
    struct HttpGetParam *phttpGetParam = (struct HttpGetParam *)param;  
    double currentTime = 0;  
    double usedTime = 0;    
  
    if ( phttpGetParam->httpStatistics.responseTime == 0)//只记录第一次收到报文时候的内容  
    {  
		QueryPerformanceCounter(&m_nCurrentUsTime);
		currentTime = (double)m_nCurrentUsTime.QuadPart;
        phttpGetParam->httpStatistics.responseTime = currentTime;   

		usedTime = (double)((currentTime - phttpGetParam->httpStatistics.requestTime)*1000/m_nFreq.QuadPart);
 
        printf("Time is : %f\r\n", usedTime);  
        printf("%s\n", (char*)ptr);
      
          
        pthread_mutex_lock(&mutex);   //上锁  
          
        m_PacketUseTime.push_back(usedTime);
  
        //Sleep(200);  
        pthread_mutex_unlock(&mutex); //解锁  
          
        if(!strcmp((char*)ptr, configvalues.HopeData))  
        {  
            RecNum = RecNum + 1;   
        }  
    }  
    return size * nmemb;  
}  




 

 

你可能感兴趣的:(55555)