I have a program that recevice message in udp in visual studio.
sometime I miss a message.I want to use select to see udp buffer used size if udp rec buffer is full.
How I can use select for this purpose?
where can I see a example?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Post-fact discovery that your receive buffer is full will not do you any good – packets have already been dropped. Even more – you need to set your buffer sizes before
connect()orbind(), they will not change after that.What you should do is pre-set socket receive buffer to some large value that would accommodate your traffic spikes, and try to process your network input faster. That usually means doing
select()on non-blocking sockets (or even better – some advanced API like Linuxepoll(7)in edge-triggered mode), and draining socket input until you getEWOULDBLOCK.Edit 0:
You cannot discover that you missed a UDP packet by using
select()or any other socket API. This has to be done in the application-level protocol, i.e. one layer up from the transport. Common practice is including sequence numbers in application message header.