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

Function socket_select

engine/script/src/luasocket/wsocket.c:78–88  ·  view source on GitHub ↗

-------------------------------------------------------------------------*\ * Select with int timeout in ms \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

76* Select with int timeout in ms
77\*-------------------------------------------------------------------------*/
78int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
79 p_timeout tm) {
80 struct timeval tv;
81 double t = timeout_get(tm);
82 tv.tv_sec = (int) t;
83 tv.tv_usec = (int) ((t - tv.tv_sec) * 1.0e6);
84 if (n <= 0) {
85 Sleep((DWORD) (1000*t));
86 return 0;
87 } else return select(0, rfds, wfds, efds, t >= 0.0? &tv: NULL);
88}
89
90/*-------------------------------------------------------------------------*\
91* Close and inutilize socket

Callers 1

global_selectFunction · 0.70

Calls 3

timeout_getFunction · 0.85
SleepFunction · 0.50
selectFunction · 0.50

Tested by

no test coverage detected