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

Function PiuDebugMachine_doCommandAux

tools/xsbug/DebugBehavior.c:1582–1638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1580}
1581
1582void PiuDebugMachine_doCommandAux(xsMachine* the, PiuDebugMachine self, void* buffer, size_t length)
1583{
1584 if (self) {
1585 #if mxLinux
1586 {
1587 const char* p = (const char*)buffer;
1588 while (length > 0) {
1589 GError* error = NULL;
1590 gssize used = g_socket_send(self->socket, p, length, NULL, &error);
1591 if (used < 0) {
1592 if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
1593 g_error_free(error);
1594 continue;
1595 }
1596 xsUnknownError("g_socket_send: %s", error->message);
1597 }
1598 p += used;
1599 length -= used;
1600 }
1601 }
1602 #elif mxMacOSX
1603 {
1604 const char* p = (const char*)buffer;
1605 while (length > 0) {
1606 ssize_t used = send(CFSocketGetNative(self->socket), p, length, 0);
1607 if (used < 0) {
1608 if ((EINTR == errno) || (EAGAIN == errno))
1609 continue;
1610 xsUnknownError("write error: %s", strerror(errno));
1611 }
1612 p += used;
1613 length -= used;
1614 }
1615 }
1616 #elif mxWindows
1617 if (self->socket != INVALID_SOCKET) {
1618 const char* p = (const char*)buffer;
1619 while (length > 0) {
1620 int used = send(self->socket, p, (int)length, 0);
1621 if (used < 0) {
1622 if (WSAEWOULDBLOCK == WSAGetLastError()) {
1623 WaitMessage();
1624 continue;
1625 }
1626 break;
1627 }
1628 p += used;
1629 length -= used;
1630 }
1631 }
1632 #endif
1633 }
1634 else {
1635 xsResult = xsGet(xsThis, xsID_connection);
1636 xsCall1(xsResult, xsID_write, xsArrayBuffer(buffer, (xsIntegerValue)length));
1637 }
1638}
1639

Callers 1

Calls 1

sendFunction · 0.85

Tested by

no test coverage detected