c udp non-blocking socket with recvfrom and select

前端 未结 1 1979
野的像风
野的像风 2021-01-03 02:16

I want to implement at the client side non-blocking socket with select function. But it doesn\'t work as expected. In the code below it never runs into else , rv is always 1

相关标签:
1条回答
  • 2021-01-03 02:51

    You set the timeout (last parameter of select) to NULL, which means it will only return once data are available on the socket (or interrupt). You need to set a timeout it should wait. The timeout might be 0 if you don't want to wait, but 0 means to use a struct timeval* with tv_sec=0 and tv_usec=0 and not use a struct timeval* of NULL like you did.

    0 讨论(0)
提交回复
热议问题