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

Function recvraw

Plugins/UnLuaExtensions/LuaSocket/Source/src/buffer.cpp:187–200  ·  view source on GitHub ↗

-------------------------------------------------------------------------*\ * Reads a fixed number of bytes (buffered) \*-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

185* Reads a fixed number of bytes (buffered)
186\*-------------------------------------------------------------------------*/
187static int recvraw(p_buffer buf, size_t wanted, luaL_Buffer *b) {
188 int err = IO_DONE;
189 size_t total = 0;
190 while (err == IO_DONE) {
191 size_t count; const char *data;
192 err = buffer_get(buf, &data, &count);
193 count = MIN(count, wanted - total);
194 luaL_addlstring(b, data, count);
195 buffer_skip(buf, count);
196 total += count;
197 if (total >= wanted) break;
198 }
199 return err;
200}
201
202/*-------------------------------------------------------------------------*\
203* Reads everything until the connection is closed (buffered)

Callers 1

buffer_meth_receiveFunction · 0.85

Calls 3

buffer_getFunction · 0.85
luaL_addlstringFunction · 0.85
buffer_skipFunction · 0.85

Tested by

no test coverage detected