title: Cannot catch send() failure with OpenAL
body: <p>I have a problem catching a moment on a client side when client is sending data in a loop and server unexpectedly shuts down.</p>
  
  <p>When I'm sending random 1024 byte chunks, everything works well and the program prints "disconnected" on server shutdown.</p>
  
  <pre><code>while (1) {
      if (send(sock, buffer, BUF_SIZE, 0) &lt; 0) {
          printf("disconnected\n");
          break;
      }
  }
  </code></pre>
  
  <p>But when I add OpenAL routines to send captured samples, the loop works the same and data are sent, but on server shutdown, the programs just exits on failed send() without giving any error and executing further code.</p>
  
  <pre><code>while (1) {
      alcGetIntegerv(device, ALC_CAPTURE_SAMPLES, (ALCsizei)sizeof(ALint), &amp;samples);
      if (samples &gt; 0) {
          buffer = realloc(buffer, samples);
          alcCaptureSamples(device, buffer, samples);
          if (send(sock, buffer, samples, 0) &lt; 0) {
              printf("disconnected\n");
              break;
          }
      }
  }
  </code></pre>
  
  <p>Does anyone know what could cause the difference?</p>