0
以下のコードは接続ハンドラ用です。今は1つの議論しかありません。それに複数の引数を渡すにはどうすればいいですか?複数の引数をcのconnection_handlerに渡していますか? connection_handlerにもう1つの整数引数を渡したい
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
}