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

Function meth_send

Plugins/UnLuaExtensions/LuaSocket/Source/src/udp.cpp:158–173  ·  view source on GitHub ↗

-------------------------------------------------------------------------*\ * Send data through connected udp socket \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

156* Send data through connected udp socket
157\*-------------------------------------------------------------------------*/
158static int meth_send(lua_State *L) {
159 p_udp udp = (p_udp) auxiliar_checkclass(L, "udp{connected}", 1);
160 p_timeout tm = &udp->tm;
161 size_t count, sent = 0;
162 int err;
163 const char *data = luaL_checklstring(L, 2, &count);
164 timeout_markstart(tm);
165 err = socket_send(&udp->sock, data, count, &sent, tm);
166 if (err != IO_DONE) {
167 lua_pushnil(L);
168 lua_pushstring(L, udp_strerror(err));
169 return 2;
170 }
171 lua_pushnumber(L, (lua_Number) sent);
172 return 1;
173}
174
175/*-------------------------------------------------------------------------*\
176* Send data through unconnected udp socket

Callers

nothing calls this directly

Calls 8

auxiliar_checkclassFunction · 0.85
luaL_checklstringFunction · 0.85
timeout_markstartFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushstringFunction · 0.85
udp_strerrorFunction · 0.85
lua_pushnumberFunction · 0.85
socket_sendFunction · 0.70

Tested by

no test coverage detected