Hi I have a bit of c code which I'm trying to use as a relay between apache and a scgi cluster.
Example of problem code is below:
while\(\(n = recv\(scgiSock, local_data, MAX_LENGTH, 0\)\) > 0\)
\{
time\(&t2\);
time_now = t2 - t1;
if\(time_now > TIMEOUT\)
throw 1;
#ifdef UN_NES_DEBUG
logger("scgi : length := ", 1, n);
#endif
logger("sending data: length = ", 1, n);
logger("send ret:= %d", 1, send(receiveSock, local_data, n, 0));
count++;
bzero(local_data, MAX_LENGTH + 1);
sum += n;
logger("Receiving data: current sum = ", 1, sum);
}
I'm encountering a slight but probably easily solveable problem; sometimes apache drops the connection and as a result my program crashes out when trying to send data back on the socket.
Is there any way to check that the socket is still alive before sending data?
Cheers.
Fish.