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

Function socket_sendto

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

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

Source from the content-addressed store, hash-verified

231* Sendto with timeout
232\*-------------------------------------------------------------------------*/
233int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent,
234 SA *addr, socklen_t len, p_timeout tm)
235{
236 int err;
237 *sent = 0;
238 if (*ps == SOCKET_INVALID) return IO_CLOSED;
239 for ( ;; ) {
240 long put = (long) sendto(*ps, data, count, 0, addr, len);
241 if (put >= 0) {
242 *sent = put;
243 return IO_DONE;
244 }
245 err = errno;
246 if (err == EPIPE) return IO_CLOSED;
247 if (err == EPROTOTYPE) continue;
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 2

meth_sendtoFunction · 0.70
meth_sendtoFunction · 0.70

Calls 1

socket_waitfdFunction · 0.70

Tested by

no test coverage detected