MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / socketReadable

Function socketReadable

modules/network/socket/qca4020/modSocket.c:412–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412void socketReadable(void *the, void *refcon, uint8_t *message, uint16_t messageLength)
413{
414 xsSocket xss = (xsSocket)refcon;
415 uint8_t buffer[kRxBufferSize];
416 int count;
417
418 if (xss->done)
419 return;
420
421 socketUpUseCount(the, xss);
422
423 count = recv(xss->skt, (char*)buffer, sizeof(buffer), 0);
424 if (count < 0) {
425 xsBeginHost(the);
426 xsCall1(xss->obj, xsID_callback, xsInteger(kSocketMsgDisconnect));
427 xsEndHost(the);
428 socketDownUseCount(the, xss);
429 doDestructor(xss);
430 return;
431 }
432 else if (count > 0) {
433 modInstrumentationAdjust(NetworkBytesRead, count);
434
435 xss->readBuffer = buffer;
436 xss->readBytes = count;
437
438 xsBeginHost(the);
439 xsCall2(xss->obj, xsID_callback, xsInteger(kSocketMsgDataReceived), xsInteger(count));
440 xsEndHost(the);
441
442 xss->readBuffer = NULL;
443 xss->readBytes = 0;
444 }
445
446 socketDownUseCount(the, xss);
447}
448
449void socketWritten(void *the, void *refcon, uint8_t *message, uint16_t messageLength)
450{

Callers 1

socketTimerCallbackFunction · 0.70

Calls 3

socketUpUseCountFunction · 0.70
socketDownUseCountFunction · 0.70
doDestructorFunction · 0.70

Tested by

no test coverage detected