-------------------------------------------------------------------------*\ * Send data through connected udp socket \*-------------------------------------------------------------------------*/
| 156 | * Send data through connected udp socket |
| 157 | \*-------------------------------------------------------------------------*/ |
| 158 | static 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 |
nothing calls this directly
no test coverage detected