I'm new in C++
and trying to create multiple threads with pthread
.
typedef struct thread_args{
int &sockfd;
struct sockaddr_in &serv_addr;
int size_serv_addr;
socklen_t &clilen;
int &newsockfd;
};
void create_server(int &sockfd, struct sockaddr_in &serv_addr, int size_serv_addr, socklen_t &clilen, int &newsockfd){
}
int main(int argc, char *argv[])
{
int sockfd, newsockfd;
socklen_t clilen;
pthread_t t1;
struct sockaddr_in serv_addr, cli_addr;
struct thread_args *args;
args->clilen = clilen;
args->newsockfd = newsockfd;
args->serv_addr = serv_addr;
args->size_serv_addr = sizeof(serv_addr);
args->sockfd = sockfd;
pthread_create(&t1, NULL, create_server, &args);
printf("hello abc");
return 0;
}
When I run this code, it has a message:
error:/bin/sh -c 'make -j 4 -e -f error: invalid conversion from 'void* (*)(int&, sockaddr_in&, int, socklen_t&, int&) {aka void* (*)(int&, sockaddr_in&, int, unsigned int&, int&)}' to 'void* (*)(void*)' [-fpermissive]
pthread_create(&t1, NULL, create_server, &args);
How can I fix this?
Aucun commentaire:
Enregistrer un commentaire