我是线程的新手,请给我建议。我有将消息广播到客户端的服务器。然后,客户端将答复发送回服务器。我想使用单独的线程处理每个答复。每个答复将具有消息ID和线程ID。如何从所有线程中使用此信息填充某些结构,然后读取它
同样从我的代码中,是否可以在一段时间内正确创建线程,或者即使我得到客户端的答复,它是否也存在于创建线程中?
我是从正确的理解开始的吗?
int main(){
while(1){
sendto on broadcast IP
pthread_create(&cln_thread, NULL, msg_processing, (void *) &arg))
}
}
msg_processing () {
recvfrom client msg with id of packet and thread id
how to write those informations and then read them in main when program finish
}
Run Code Online (Sandbox Code Playgroud)
谢谢