I am sharing a code for “UDP Server C++ Class with a listening thread”. In the class “UDPThread”, a thread is running to receive a UDP packet.
Just compile a demo program with this command. Then you will understand.
g++ demo_udp_server.cpp UDPThread.cpp -lpthread -o demo_udp_server
This is the result.
I hope this code helps your project.