Hi, I am looking for a way to check if a socket is still connected to the client.
What is a good way to do this in APR? Here are some tries which do not work
(on Win32 with the cvs co latest):


1) send 0 bytes -- failed to detect connection loss, probably due to buffering:

int n = 0;
int e = apr_send(sock, (char*) NULL, &n);
if (e)  not_connected();

2) recv 0 bytes -- blocked in definitely:

int n = 0;
int e = apr_recv(sock, (char*) NULL, &n);
if (e)  not_connected();

3) query APR_SO_DISCONNECTED -- always return connection OK:

int n, e;
e = apr_socket_opt_get(sock, APR_SO_DISCONNECTED, &n);
if (e || n) not_connected();


Thanks, -cktan





Reply via email to