UDT Reference

UDT Reference: Functions

#### selectEx

The selectEx method queries a group of of UDT sockets for IO status.

Note: selectEx is deprecated. Please use epoll instead, which is far more efficienct.

int selectEx(
std::vector<UDTSOCKET> fds,
std::vector<UDTSOCKET>* readfds,
std::vector<UDTSOCKET>* writefds,
std::vector<UDTSOCKET>* exceptfds,
const int64_t msTimeOut
);

##### Parameters

fds
  [in] the group of UDT socket descriptors to be queried, in a C++ vector.
readfds
  [out] Optional pointer to a set of sockets that are ready for recv.
writefds
  [out] Optional pointer to a set of sockets that are ready for send.
exceptfds
  [out] Optional pointer to a set of sockets that are closed or with a broken connection.
msTimeOut
  [in] The time that this function should wait for the status change in the input groups, in milliseconds.

##### Return Value

If any of the read, write, or except group is not empty, selectEx returns the number of UDT sockets that are read for read/write or are broken/closed. If no socket is ready before timeout, zero is returned. If there is any error, UDT::ERROR is returned and the specific error information can be retrieved using getlasterror. The readfds,writefds and/or exceptfds will be updated to contain the ready sockets.

Error Name | Error Code | Comment
EINVPARAM | 5003 | All three socket sets are NULL or at least one of the socket is invalid.

##### Description

This function selectEx is an advanced version of select. In contrast to select, selectEx does not modify the input parameter fds, so that applications do not need to replicate or initialize it every time the function is called.

The new function only has one group of input socket descriptors. If a particular event check is not necessary, the corresponding output parameter can be set to NULL. For example, if the application does not care about if a socket is ready for send, the parameter writefds can be NULL.

Finally, selectEx specifies the absolute amount of time to wait, while select requires a clock time in the future to wait until.

Overall, selectEx is more convinient and more efficient.

##### See Also

select, epoll