S
S
sitev_ru2015-06-03 14:03:58
Android
sitev_ru, 2015-06-03 14:03:58

Why can the program crash here?

If I send it to a regular computer, then it's normal, but if it's on Android, it crashes...

bool Socket::sendAll(void *buffer, int size) {
  if (!isValid()) return 0;
  char *ptr = (char*) buffer;

  int counter = 0;
  while (size > 0)
  {
    int sz = ::send(m_sock, ptr, size, 0);
    usleep(1000);
    if (sz < 1) {
      counter++;
      if (counter > 10000) return false;
      continue;
    }
    ptr += sz;
    size -= sz;
  }

  return true;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TriKrista, 2015-06-03
@TriKrista

As a variant of the buffer variable, memory is not always allocated

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question