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

Function socket_accept

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

-------------------------------------------------------------------------*\ * Accept with timeout \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

177* Accept with timeout
178\*-------------------------------------------------------------------------*/
179int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len,
180 p_timeout tm) {
181 if (*ps == SOCKET_INVALID) return IO_CLOSED;
182 for ( ;; ) {
183 int err;
184 /* try to get client socket */
185 if ((*pa = accept(*ps, addr, len)) != SOCKET_INVALID) return IO_DONE;
186 /* find out why we failed */
187 err = WSAGetLastError();
188 /* if we failed because there was no connectoin, keep trying */
189 if (err != WSAEWOULDBLOCK && err != WSAECONNABORTED) return err;
190 /* call select to avoid busy wait */
191 if ((err = socket_waitfd(ps, WAITFD_R, tm)) != IO_DONE) return err;
192 }
193}
194
195/*-------------------------------------------------------------------------*\
196* Send with timeout

Callers

nothing calls this directly

Calls 1

socket_waitfdFunction · 0.70

Tested by

no test coverage detected