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

Function socket_select

Plugins/UnLuaExtensions/LuaSocket/Source/src/wsocket.cpp:84–94  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

timeout_getFunction · 0.85

Tested by

no test coverage detected