现在的位置: 首页 > 综合 > 正文

嵌入式 Linux下线程的创建和启动

2014年12月12日 ⁄ 综合 ⁄ 共 798字 ⁄ 字号 评论关闭

 int tmp,i;
 pthread_t thread;
 pthread_attr_t    attr;
 int data_len = 6 ;
 sock_attr->ssl_connection = 1;
 sock_attr->status = 0;
 do{

  if(sock_attr->ssl_connection){
   
   sock_attr->joseph_sock_write= joseph_ssl_write;
   sock_attr->joseph_sock_read= joseph_ssl_read;
   //createssl_new after the created fo the sockted
   sock_attr->ssl= SSL_new(sock_attr->ctx);
   SSL_set_fd(sock_attr->ssl,sock_attr->sockfd);
   tmp =SSL_accept(sock_attr->ssl);
   if(tmp< 0){
    //SSL_shutdown(sock_attr->ssl);
    break;
   }
   sock_attr->status= CONNECTION_STATUS_SSL;

  }
  
  pthread_attr_init(&attr);
  pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE);
  pthread_create(&thread,&attr, jss_ssl_thr,(void*)sock_attr);
  pthread_join(thread,NULL);
  //if(sock_attr->ssl_connection)SSL_shutdown(sock_attr->ssl); //alert to the peer
  
 }while(0);

抱歉!评论已关闭.