0
下面的代碼是針對連接處理程序的。現在它只有一個參數。我如何向它傳遞多於一個參數在c中傳遞多個參數給connection_handler?我想傳遞一個整數參數給connection_handler
while(client_sock=accept(socket_desc,(struct sockaddr*)&client,
(socklen_t*)&c))
{
puts("Connection accepted");
pthread_t sniffer_thread;
new_sock = malloc(1);
*new_sock = client_sock;
if(pthread_create(&sniffer_thread , NULL , connection_handler ,
(void*) new_sock) < 0)
{
perror("could not create thread");
`enter code here`return 1;
}
puts("Handler assigned");
}
void *connection_handler(void *socket_desc)
{
x++;
//code for connection handler
}