pthread_create传递参数

 CIniFile thini("./preconfig.ini");
 string strip="";
 string strport="";
 strip=thini.readStr("server","ip");
 strport=thini.readStr("server","port");
 
   struct argument arg1;
   arg1.ip=strip;
   arg1.port=strport;
	pthread_t id;
	        int ret = pthread_create(&id, NULL, thread, (void*)&arg1);

  

void *thread7(void *ptr)
{
	C_Ctp tp;
  struct argument arg_thread;
   arg_thread =*(struct argument*)ptr;

 tp.SetIpAddr(arg_thread.ip.c_str(),arg_thread.port.c_str());
 tp.Connect();
 int i = 0;
 for(i=0; i<100;i++)
 tp.PreDeal("50001");
    return 0;
}

  

posted on 2020-08-07 12:50  lydstory  阅读(477)  评论(0)    收藏  举报

导航