MCPcopy Create free account
hub / github.com/defold/defold / socket_select

Function socket_select

engine/script/src/luasocket/usocket.c:106–118  ·  view source on GitHub ↗

-------------------------------------------------------------------------*\ * Select with timeout control \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

104* Select with timeout control
105\*-------------------------------------------------------------------------*/
106int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
107 p_timeout tm) {
108 int ret;
109 do {
110 struct timeval tv;
111 double t = timeout_getretry(tm);
112 tv.tv_sec = (int) t;
113 tv.tv_usec = (int) ((t - tv.tv_sec) * 1.0e6);
114 /* timeout = 0 means no wait */
115 ret = select(n, rfds, wfds, efds, t >= 0.0 ? &tv: NULL);
116 } while (ret < 0 && errno == EINTR);
117 return ret;
118}
119
120/*-------------------------------------------------------------------------*\
121* Creates and sets up a socket

Callers

nothing calls this directly

Calls 2

timeout_getretryFunction · 0.85
selectFunction · 0.50

Tested by

no test coverage detected