apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From C K Tan <ck...@nxscientific.com>
Subject apr_socket connection status check
Date Tue, 20 Aug 2002 17:48:08 GMT
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  
(on Win32 with the cvs co latest):

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

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();


View raw message