MCPcopy Create free account
hub / github.com/Tencent/UnLua / socket_select

Function socket_select

Plugins/UnLuaExtensions/LuaSocket/Source/src/usocket.cpp:107–119  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 1

global_selectFunction · 0.70

Calls 1

timeout_getretryFunction · 0.85

Tested by

no test coverage detected