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

Function socket_accept

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

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

Source from the content-addressed store, hash-verified

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

Callers 2

meth_acceptFunction · 0.70
inet_tryacceptFunction · 0.70

Calls 1

socket_waitfdFunction · 0.70

Tested by

no test coverage detected