1

I know both of this can be used to set timeout of recvfrom(), but which one is better? Intuitively, setsockopt seems simple to use, but I found many examples are using select(). I only use a single socket and the timeout is recalculated in transmission(I am using Ubuntu).

Rapidturtle
  • 217
  • 1
  • 3
  • 13

1 Answers1

0

It depends on your exact requirement/scenario that you are looking to use it.

In general, select allows you to monitor several sockets at the same time. Incase your design has multiple sockets, then usage of select is preferred. However, if you are going to have only one socket, then the option of using timeout (SO_RCVTIMEO) with setsockopt is a better option.

Karthik Balaguru
  • 7,424
  • 7
  • 48
  • 65