MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / SocketAPM_sendfile

Function SocketAPM_sendfile

libraries/AP_Scripting/lua_bindings.cpp:975–993  ·  view source on GitHub ↗

socket sendfile, for offloading file send to AP_Networking */

Source from the content-addressed store, hash-verified

973 socket sendfile, for offloading file send to AP_Networking
974 */
975int SocketAPM_sendfile(lua_State *L) {
976 binding_argcheck(L, 2);
977
978 SocketAPM *ud = *check_SocketAPM(L, 1);
979
980 auto *p = (luaL_Stream *)luaL_checkudata(L, 2, LUA_FILEHANDLE);
981 int fd = p->f->fd;
982
983 bool ret = fd != -1 && AP::network().sendfile(ud, fd);
984 if (ret) {
985 // the fd is no longer valid. The lua script must
986 // still call close() to release the memory from the
987 // socket
988 p->f->fd = -1;
989 }
990
991 lua_pushboolean(L, ret);
992 return 1;
993}
994
995/*
996 receive from a socket to a lua string

Callers

nothing calls this directly

Calls 3

luaL_checkudataFunction · 0.85
lua_pushbooleanFunction · 0.85
sendfileMethod · 0.80

Tested by

no test coverage detected