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

Function socket_sendto

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

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

Source from the content-addressed store, hash-verified

227* Sendto with timeout
228\*-------------------------------------------------------------------------*/
229int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent,
230 SA *addr, socklen_t len, p_timeout tm)
231{
232 int err;
233 *sent = 0;
234 if (*ps == SOCKET_INVALID) return IO_CLOSED;
235 for ( ;; ) {
236 int put = sendto(*ps, data, (int) count, 0, addr, len);
237 if (put > 0) {
238 *sent = put;
239 return IO_DONE;
240 }
241 err = WSAGetLastError();
242 if (err != WSAEWOULDBLOCK) return err;
243 if ((err = socket_waitfd(ps, WAITFD_W, tm)) != IO_DONE) return err;
244 }
245}
246
247/*-------------------------------------------------------------------------*\
248* Receive with timeout

Callers

nothing calls this directly

Calls 1

socket_waitfdFunction · 0.70

Tested by

no test coverage detected