| 410 | } |
| 411 | |
| 412 | void 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 | |
| 449 | void socketWritten(void *the, void *refcon, uint8_t *message, uint16_t messageLength) |
| 450 | { |
no test coverage detected