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

Function socket_sendto

engine/script/src/luasocket/usocket.c:234–253  ·  view source on GitHub ↗

-------------------------------------------------------------------------*\ * Sendto with timeout \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

232* Sendto with timeout
233\*-------------------------------------------------------------------------*/
234int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent,
235 SA *addr, socklen_t len, p_timeout tm)
236{
237 int err;
238 *sent = 0;
239 if (*ps == SOCKET_INVALID) return IO_CLOSED;
240 for ( ;; ) {
241 long put = (long) sendto(*ps, data, count, 0, addr, len);
242 if (put >= 0) {
243 *sent = put;
244 return IO_DONE;
245 }
246 err = errno;
247 if (err == EPIPE) return IO_CLOSED;
248 if (err == EINTR) continue;
249 if (err != EAGAIN) return err;
250 if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err;
251 }
252 return IO_UNKNOWN;
253}
254
255/*-------------------------------------------------------------------------*\
256* Receive with timeout

Callers

nothing calls this directly

Calls 1

socket_waitfdFunction · 0.70

Tested by

no test coverage detected