in nailgun-client/c/ng.c [226:256]
void sendChunk(unsigned int size, char chunkType, char* buf) {
/* buffer used for reading and writing chunk headers */
char header[CHUNK_HEADER_LEN];
int bytesSent;
header[0] = (size >> 24) & 0xff;
header[1] = (size >> 16) & 0xff;
header[2] = (size >> 8) & 0xff;
header[3] = size & 0xff;
header[4] = chunkType;
#ifdef WIN32
if (WaitForSingleObject(sending, INFINITE) != WAIT_OBJECT_0) {
handleError();
}
#else
gettimeofday(&sendtime, NULL);
#endif
bytesSent = sendAll(nailgunsocket, header, CHUNK_HEADER_LEN);
if (bytesSent != 0 && size > 0) {
bytesSent = sendAll(nailgunsocket, buf, size);
} else if (bytesSent == 0 && (chunkType != CHUNKTYPE_HEARTBEAT || !(errno == EPIPE || errno == ECONNRESET))) {
perror("send");
handleSocketClose();
}
#ifdef WIN32
ReleaseMutex(sending);
#endif
}