2012-09-24 49 views
0

正在嘗試一個SSL結構傳遞給一個線程,但我無法用下面的代碼來實現相同的,通SSL結構向線程

if(SSL_set_fd(ssl, client_s)<0) 
    printf("\n error in assigning socket to SSL:"); 
else 
    printf("\n The socket has been assigned to SSL Structure"); 



    pthread_create (     /* Create a child thread  */ 
       &threads,    /* Thread ID (system assigned) */  
       &attr,     /* Default thread attributes */ 
       my_thread,    /* Thread routine    */ 
       &ssl);  

} 

void *my_thread(void * arg) 
{ 
SSL *ssl1; 
ssl1 = *(SSL)arg; 
int i=1,err,fh,ret;//i 
unsigned int buf_len; 

錯誤我得到的是如下:

錯誤:轉換到非標量型要求

回答

0

據我知道你總是得到一個指向SSL結構,所以這裏是你的更正後的代碼:

pthread_create (     /* Create a child thread  */ 
      &threads,    /* Thread ID (system assigned) */  
      &attr,     /* Default thread attributes */ 
      my_thread,    /* Thread routine    */ 
      ssl);  

而且裏面你線程函數:

void *my_thread(void * arg) 
{ 
    SSL *ssl1; 
    ssl1 = (SSL*)arg; 

你想在你的「在pthread_create」通行證「指針的指針」呼和鑄造裏面「my_thread」也是不正確。